About zero-byte receive (IOCP server)



Hi,

As you already know I work hard to develop a robust IOCP server with your
help :)

My new issue is about zero-byte receives. From my researches,I have learned
that to overcome WSAENOBUF problem (the one caused by large amount of locked
memory) I should post a receive with zero-length buffer for every accepted
client. On completion of that receive I can post actual receive and read
data. But how? How should I call WSARecv () at that point to read data
efficiently (Blocking, non-blocking or posting to completion port)?

A book says : "...once the zero-byte receive operation completes, the server
can simply perform a non-blocking receive to retrieve all the data buffered
in the socket's receive buffer. There is no more data pending when the
non-blocking receive fails with WSAEWOULDBLOCK..."

As far as understand the excerpt, I should make the socket non-blocking
everytime a zero-byte receive completes for that socket by using
ioctlsocket (...). Then I should read data by calling WSARecv () until
WSAGetLastError () returns WSAEWOULDBLOCK. After that I should post another
zero-byte read using same socket. But I have made the socket non-blocking,
does it prevent using same socket with overlapped calls to WSARecv () which
I use to post zero-byte receive? Why should I make non-blocking calls to
read actual data instead of posting to completion port?

I know, nature of the communication between clients and server determine
answers to obove questions but your general advices could help me to find
most appropriate way to implement this part of my server.

Thanks in advance.


.



Relevant Pages

  • Re: Network programming
    ... > Basically I need writeto be non-blocking. ... > For example, suppose I am streaming data from a server to a client, ... The FIFO needs to be ... Start a thread that loops reading the FIFO and writing the socket. ...
    (comp.lang.java.programmer)
  • Re: About zero-byte receive (IOCP server)
    ... zero-byte receives in any IOCP server. ... sockets.The problem is that on completion of a zero-byte receive IOCP ... On a zero-byte recv you don't have to read all the data, ... client socket will be constantly sending in data and you could end up ...
    (microsoft.public.win32.programmer.networks)
  • Re: select() indicates writability before a non-blocking TCP socket has actually connected
    ... notifications while the server is unavailable. ... the socket is closed and a new socket along with a new call to ... it's indicating that a writecall will not block. ... because it's a non-blocking socket. ...
    (comp.os.linux.development.apps)
  • Re: About zero-byte receive (IOCP server)
    ... sockets.The problem is that on completion of a zero-byte receive IOCP worker ... the socket to non-blocking mode and then issue non-overlapped,non-blocking ... On a zero-byte recv you don't have to read all the data, ... here, lets say the client has a high-speed connection, in this case the ...
    (microsoft.public.win32.programmer.networks)
  • Re: About zero-byte receive (IOCP server)
    ... sockets.The problem is that on completion of a zero-byte receive IOCP worker ... 1- In this framework only one thread can serve a socket at a given time if I ... can accept more client connections and can handle more IO before it reach ...
    (microsoft.public.win32.programmer.networks)

Loading