Re: CSocket 10038 WSAENOTSOCK Error
cleohm wrote:
Hi,
I am currently implementing a server socket that listen to a particular port
on the local machine as well as another client socket that connect to the
same port on the same machine. Everything goes fine until I attempt to send
data using the client socket. When I call GetLastError(), I got the error
code 10038 - WSAENOTSOCK.
I suspect that the error is due to me trying to listen and connect on the
same port and address. I tried to use SetSockOpt as follow:
serverSocket->SetSockOpt(SO_REUSEADDR, &nOption, 1);
It is still not successful. Does anyone have any idea how I can resolve
this problem?
There are two port numbers associated with a client socket. One of them
is the client's own and the other is the server to call. When calling a
server on the same machine these two port numbers must be different
because the IP:port pair is used to uniquely identify each socket.
Typical practice is to let the system select the client's own port (pass
NULL to CSocket::Create, and pass the server port to CSocket::Connect).
CSocket is part of the MFC library, so if you have follow up questions
try the MFC newsgroup for best results.
--
Scott McPhillips [VC++ MVP]