CSocket Bind Invalid Argument Error
-
I am trying to create a UDP connection using the CSocket class. The code I have so far is this:
CSocket sock; //Create socket if (!sock.Create(0, SOCK_DGRAM, NULL)) { GetSocketError(); //Get Socket's Last Error return -1; } //__if (!sock.Create(...))__ //Bind socket if(!sock.Bind((UINT)4200, _T("127.0.0.1"))) { GetSocketError(); //Get Socket's Last Error return -1; } //__if(sock.Bind(...))__
The call to Create() works without a problem but when I try to bind to the port and address I get an "Invalid Argument (10022)" error. Any suggestions? Thanks. -
I am trying to create a UDP connection using the CSocket class. The code I have so far is this:
CSocket sock; //Create socket if (!sock.Create(0, SOCK_DGRAM, NULL)) { GetSocketError(); //Get Socket's Last Error return -1; } //__if (!sock.Create(...))__ //Bind socket if(!sock.Bind((UINT)4200, _T("127.0.0.1"))) { GetSocketError(); //Get Socket's Last Error return -1; } //__if(sock.Bind(...))__
The call to Create() works without a problem but when I try to bind to the port and address I get an "Invalid Argument (10022)" error. Any suggestions? Thanks.Did u see what does error 10022 mean?
KIRAN PINJARLA
-
Did u see what does error 10022 mean?
KIRAN PINJARLA
Yes... it's an "Invalid Argument" error: WSAEINVAL (10022) Invalid argument. Some invalid argument was supplied (for example, specifying an invalid level to the setsockopt function). In some instances, it also refers to the current state of the socket - for instance, calling accept on a socket that is not listening.
-
I am trying to create a UDP connection using the CSocket class. The code I have so far is this:
CSocket sock; //Create socket if (!sock.Create(0, SOCK_DGRAM, NULL)) { GetSocketError(); //Get Socket's Last Error return -1; } //__if (!sock.Create(...))__ //Bind socket if(!sock.Bind((UINT)4200, _T("127.0.0.1"))) { GetSocketError(); //Get Socket's Last Error return -1; } //__if(sock.Bind(...))__
The call to Create() works without a problem but when I try to bind to the port and address I get an "Invalid Argument (10022)" error. Any suggestions? Thanks.masnu wrote:
if(!sock.Bind((UINT)4200, _T("127.0.0.1")))
why dont you try with NULL as the second parameter?
-
masnu wrote:
if(!sock.Bind((UINT)4200, _T("127.0.0.1")))
why dont you try with NULL as the second parameter?