Advertisement

Wierd error

Started by May 17, 2003 03:51 PM
7 comments, last by Annon 21 years, 8 months ago
I''m trying to make a simple multithreaded client-server connection. The client can connect to the server. Then WSASend or WSARecv will return SOCKET_ERROR but a subsequent call to WSAGetLastError returns 0. How is this possible?
Did you initialize Winsock with a call to WSAStartup()?
Advertisement
maybe it is not error, there is nonblocking or overlapped socket functions.

WSARecv or WSASend was maintained in background.

So there is not error...

Good Luck
WSAStartup() is called and the socket is blocking.

Any other ideas?
Are you by any chance doing the following:

int err = WSARecv(...);
if ( err = SOCKET_ERROR ) //-- assignemnt, not compare
{
}

Otherwise I don''t see how you could get a null error on an error from a WSA call.

-cb
um...

so... that is not error [ blocking mode ]

it is possible in follow...

1. 0 bytes sending [or immediatly returned]

int WSASend(
SOCKET s,
LPWSABUF lpBuffers,
DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent,
DWORD dwFlags,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);

notice lpNumberOfBytesSent.

2. receving closing or connection SYNC with WSARecv
3. using Completion Routine

but...

i can''t see your situation as your said.
is sure blocking mode?
Advertisement
ah. my mistake.

WSARecv, WSASend is not blocking API

understand? this is OVERLAPPED I/O, not blocking.

compare WSARecv and recv in WINSOCK.

if data was not incoming, WSARecv has returned but recv has not returned before data was incoming. In other words, recv has blocking mode until data was not incoming.

[edited by - veruna2k on May 19, 2003 11:11:49 PM]
thx Veruna

I changed it to send/recv and it works.
quote:
Original post by veruna2k
ah. my mistake.

WSARecv, WSASend is not blocking API

understand? this is OVERLAPPED I/O, not blocking.

compare WSARecv and recv in WINSOCK.

if data was not incoming, WSARecv has returned but recv has not returned before data was incoming. In other words, recv has blocking mode until data was not incoming.

[edited by - veruna2k on May 19, 2003 11:11:49 PM]


Wrong.

WSARecv/WSASend exhibit the exact same behaviour as recv/send when the lpOverlapped and lpCompletionRoutine parameters are set to NULL.

The error must have been something else.

[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com

This topic is closed to new replies.

Advertisement