Advertisement

Asynchronous Sockets and Server-Side send()

Started by March 04, 2005 03:36 PM
3 comments, last by jtmerchant 19 years, 11 months ago
Using asynchronous sockets, could I (when I get the FD_ACCEPT notification in WinProc as the server) call send() immediately after calling accept()? Or do I have to wait for the client to recieve the FD_CONNECT notification?
Absolutely. You can call send() right after accept(). Generally, check out the non-blocking winsock API such as WSAAccept() and WSASend().

Kuphryn
Advertisement
Really? When I get the message on the client program via a FD_READ notification, recv() returns -1 and WSAGetLastError returns WSAEWOULDBLOCK, and no other FD_READ notification gets sent. Am I just supposed to while(1) recv() or something until it works?

[Edited by - jtmerchant on March 5, 2005 9:55:12 AM]
Oh and the server gets WSAENOTCONN from WSAGetLastError() after send() returns SOCKET_ERROR.
Oops. On MSDN's example it shows send( m_socket, sendbuf, strlen(sendbuf), 0 ) where m_socket was the socket they used as the server, but I tried using the socket returned from accept() and it worked.

This topic is closed to new replies.

Advertisement