Archived

This topic is now archived and is closed to further replies.

kuphryn

Interesting Problem with IOCP and AcceptEx() :: Winsock

Recommended Posts

Hi, I am working on a winsock applications that utilize IOCP and AcceptEx() winsock extension. Basically, the program is a client/server and can send and receive data. Here is the program. - server activates IOCP and AcceptEx() listening on port 1000 - client activates IOCP and AcceptEx() listening on port 1000 ... - server sends a package to client (server -> data -> client) ... - server processes incoming socket from AcceptEx(). At this point, the incoming data is valid. Everything looks good and valid. I tested this via sending of ASCII test. Everything looks valid. - client process the data and sends data back to server (client -> data -> server). For some reason, the server never receives the data. IOCP acknowledged the WSASend() post. It even returns the size of the packet. However, the server never receives the packet. At this point, I have no idea what is causing the problem. At any given time, both client and server can make NEW connections and send data with the initial packet. However, once the other side receives the incoming connection, processes data, and sends back a response, the response DOES NOT arrive. Please post if you have any idea as to what is causing this problem. I am not too familiar with AcceptEx() in terms of any specific API that must be called once a socket has been accepted. I did implement setsockopt(). Thanks, Kuphryn

Share this post


Link to post
Share on other sites
I check it very thoroughly. The buffer object registers the correct data. WSASend() sends the correct number of bytes. IOCP on the sending process reports the correct number of bytes sent.

Again, the problem is still that the receiving process never receives the data.

Kuphryn

Share this post


Link to post
Share on other sites
Okay, I''ll make one other suggestion, since you say your buffers are okay. Did you post enough reads on both the client and server?

In my server (which is IOCP), I take 10 of my buffers and call WSARecvFrom() (I use UDP) on each of them. This puts some buffers into read mode so they can catch incoming datagrams.

When I get a read completion notification, I stick the used buffer into a queue for processing by my main thread. I then replace the used up buffer by grabbing a new one and posting another WSARecvFrom() on it. I always have 10 buffers ready to catch incoming datagrams. And I''m probably going to raise that number to something more like 50 at some point.

I dunno, maybe you already have enough pending read buffers in place. But if you forgot and don''t have any ready (or just used one and forgot to replace it after the first recieve), that could cause that problem. It''s about the only other thing I can think of

One other nit-picky comment, which you can ignore if you like. Clients (in a Client/Server model) don''t generally need to use IOCP. Unless you have some sort of odd setup, clients have one connection to deal with, the server. Using IOCP for one connection is a little bit of overkill My server is IOCP, and my clients are asynchronous sockets.

Share this post


Link to post
Share on other sites
Thanks.

Yeah, I like IOCP because of the performance. The client can potentially make multiple connections.

I still have not been able to pinpoint the problem. I''ll check out your suggestion.

Kuphryn

Share this post


Link to post
Share on other sites