Why does WinSock 2.0 send() function think the Socket passed to it is not a socket ?
int ret = send(Socket, buf, 1, 0);
if ( SOCKET_ERROR == nRet ) // ret is SOCKET_ERROR
{
DWORD dwError = WSAGetLastError(); // error is 10038 Not a socket.
}
If the error is ignored the data is sent anyway, so how can it not be a socket !
Somwhere at the start of my code
ULONG ulRetCode = 0;
WSADATA WSAData = {0};
if ( 0 != ( ulRetCode = WSAStartup(MAKEWORD(2, 2), &WSAData)))
{
return ulRetCode;
}
return ulRetCode; returns here OK everytime.
Socket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
Receiving data from the bluetooth device works just fine.
My code is non-blocking. In an attempt nail down this send() problem I also made a project that uses blocking calls.
Both cases send() thinks the socket is not a socket... and if the code ignores the eror it works just fine.
I also tried WSASend() non-overlapped and it does the same thing...
Is there known problem with send() ?
Start Free Trial