Click here to Skip to main content
15,897,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCListBox, Items underline Pin
Member 130581126-Aug-04 2:14
Member 130581126-Aug-04 2:14 
GeneralRe: CListBox, Items underline Pin
David Salter26-Aug-04 2:45
David Salter26-Aug-04 2:45 
GeneralRe: CListBox, Items underline Pin
Member 130581126-Aug-04 23:46
Member 130581126-Aug-04 23:46 
GeneralRe: CListBox, Items underline Pin
rotu27-Aug-04 0:37
rotu27-Aug-04 0:37 
GeneralInstallShield Developer 7 launching multiple msi from setup/master msi Pin
TssPrasad26-Aug-04 2:14
sussTssPrasad26-Aug-04 2:14 
GeneralUnable to create a server Pin
Anonymous26-Aug-04 2:08
Anonymous26-Aug-04 2:08 
GeneralRe: Unable to create a server Pin
4apai26-Aug-04 2:25
4apai26-Aug-04 2:25 
GeneralRe: Unable to create a server Pin
Tom Wright26-Aug-04 6:41
Tom Wright26-Aug-04 6:41 
Okay I'm going to make an attempt to answer this.
Anonymous wrote:
void CMultiAPIDlg::OnBConnect()
{
m_connectsocket.Create ( 0 ) ;
m_connectsocket.Connect ( m_server, m_port) ;
}


This should be a create then a listen. Like this
void CMultiAPIDlg::OnBConnect() <br />
{<br />
m_listensocket.Create ( m_port ) ;<br />
m_listensocket.Listen ( ) ;<br />
}


The Create is where you specifiy what port you want your server listening on. Next you must listen for a connection. Also to make it easier switch your class reference around to reflect your app. For servers they listen, for clients they connect. So in the code above I switched the references around. Now just accept your connection just like you have it.


One last suggestion in your mysocket class, in the onconnect, I would do something like this:

	if (nErrorCode != 0)<br />
	{<br />
	switch( nErrorCode )<br />
		{<br />
		case WSAEADDRINUSE: <br />
			AfxMessageBox("The specified address is already in use.\n");<br />
			break;<br />
		case WSAEADDRNOTAVAIL: <br />
			AfxMessageBox("The specified address is not available from the local machine.\n");<br />
			break;<br />
		case WSAEAFNOSUPPORT: <br />
			AfxMessageBox("Addresses in the specified family cannot be used with this socket.\n");<br />
			break;<br />
		case WSAECONNREFUSED: <br />
			AfxMessageBox("The attempt to connect was forcefully rejected.\n");<br />
			break;<br />
		case WSAEDESTADDRREQ: <br />
			AfxMessageBox("A destination address is required.\n");<br />
			break;<br />
		case WSAEFAULT: <br />
			AfxMessageBox("The lpSockAddrLen argument is incorrect.\n");<br />
			break;<br />
		case WSAEINVAL: <br />
			AfxMessageBox("The socket is already bound to an address.\n");<br />
			break;<br />
		case WSAEISCONN: <br />
			AfxMessageBox("The socket is already connected.\n");<br />
			break;<br />
		case WSAEMFILE: <br />
			AfxMessageBox("No more file descriptors are available.\n");<br />
			break;<br />
		case WSAENETUNREACH: <br />
			AfxMessageBox("The network cannot be reached from this host at this time.\n");<br />
			break;<br />
		case WSAENOBUFS: <br />
			AfxMessageBox("No buffer space is available. The socket cannot be connected.\n");<br />
			break;<br />
		case WSAENOTCONN: <br />
			AfxMessageBox("The socket is not connected.\n");<br />
			break;<br />
		case WSAENOTSOCK: <br />
			AfxMessageBox("The descriptor is a file, not a socket.\n");<br />
			break;<br />
		case WSAETIMEDOUT: <br />
			AfxMessageBox("The attempt to connect timed out without establishing a connection. \n");<br />
			break;<br />
		default:<br />
			TCHAR szError[256];<br />
			wsprintf(szError, "OnConnect error: %d", nErrorCode);<br />
			AfxMessageBox(szError);<br />
			break;<br />
}


That way you know why your not connecting.

Hope this helps

Tom Wright
tawright915@yahoo.com
GeneralRe: Unable to create a server Pin
palbano26-Aug-04 8:36
palbano26-Aug-04 8:36 
GeneralRe: Unable to create a server Pin
Anonymous26-Aug-04 16:20
Anonymous26-Aug-04 16:20 
GeneralRe: Unable to create a server Pin
Anonymous26-Aug-04 17:04
Anonymous26-Aug-04 17:04 
GeneralRe: Unable to create a server Pin
palbano26-Aug-04 17:57
palbano26-Aug-04 17:57 
GeneralGet Token from SID Pin
4apai26-Aug-04 1:44
4apai26-Aug-04 1:44 
GeneralCLSID to char* Pin
anderslundsgard26-Aug-04 1:38
anderslundsgard26-Aug-04 1:38 
GeneralRe: CLSID to char* Pin
4apai26-Aug-04 1:48
4apai26-Aug-04 1:48 
GeneralRe: CLSID to char* Pin
anderslundsgard26-Aug-04 2:13
anderslundsgard26-Aug-04 2:13 
GeneralSave binary files in Access DB (ADO) Pin
Yaelinka26-Aug-04 1:37
Yaelinka26-Aug-04 1:37 
GeneralRe: Save binary files in Access DB (ADO) Pin
Scozturk26-Aug-04 1:53
professionalScozturk26-Aug-04 1:53 
GeneralRe: Save binary files in Access DB (ADO) Pin
Yaelinka26-Aug-04 1:55
Yaelinka26-Aug-04 1:55 
GeneralRe: Save binary files in Access DB (ADO) Pin
4apai26-Aug-04 2:11
4apai26-Aug-04 2:11 
GeneralRe: Save binary files in Access DB (ADO) Pin
Yaelinka26-Aug-04 2:18
Yaelinka26-Aug-04 2:18 
GeneralRe: Save binary files in Access DB (ADO) Pin
4apai26-Aug-04 2:35
4apai26-Aug-04 2:35 
GeneralRe: Save binary files in Access DB (ADO) Pin
Yaelinka26-Aug-04 3:56
Yaelinka26-Aug-04 3:56 
GeneralRe: Save binary files in Access DB (ADO) Pin
David Crow26-Aug-04 4:09
David Crow26-Aug-04 4:09 
QuestionGetMenuPosFromID.. wtf?? Pin
Jörgen Sigvardsson25-Aug-04 23:56
Jörgen Sigvardsson25-Aug-04 23:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.