|
-
March 27th, 2011, 07:00 PM
#1
socket function returning = 10038
Code:
bool CSocketComm::ConnectTo(LPCTSTR strDestination, LPCTSTR strServiceName, int nFamily, int nType){
// Socket is already opened
if ( IsOpen() ){
return false;
}
// Create a Socket that is bound to a specific service provide
// nFamily: (AF_INET)
// nType: (SOCK_STREAM, SOCK_DGRAM)
WSASetLastError(0);
SOCKET sock = socket(nFamily, nType, 0);
if (INVALID_SOCKET != sock){
// Associate a local address with the socket
SockAddrIn sockAddr;
if (false == sockAddr.CreateFrom(NULL, TEXT("0"), nFamily)){
closesocket( sock );
return false;
}
if ( SOCKET_ERROR == bind(sock, sockAddr, sockAddr.Size() )){
closesocket( sock );
return false;
}
// Now get destination address & port
sockAddr.CreateFrom( strDestination, strServiceName );
// try to connect - if fail, server not ready
if (SOCKET_ERROR == connect( sock, sockAddr, sockAddr.Size())){
closesocket( sock );
return false;
}
// Success, now we may save this socket
m_hComm = (HANDLE) sock;
Inactive=false;
//Allocacion para el IncBuffer
IncBuffer.reserve(1024*512); //512 KB
//Reseting
Porcentaje=0;
Total=0;
Progreso=0;
PckType=0;
}else{
Fncs.Loguear("socket returned Invalid Handle",WSAGetLastError());
}
//Fncs.Loguear("WSAErr",WSAGetLastError());
return (INVALID_SOCKET != sock);
}
why would the socket Function return INVALID_SOCKET and in the WSAGetLastError return 10038
Wich is:
WSAENOTSOCK
10038
Socket operation on nonsocket.
An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.
when on the socket function documentation 10038 is not a valid error code for its call
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
may be regarded to the buffer i dont know what to think this is being cracking me.
Thx In Advance!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|