Interesting Problem with IOCP and AcceptEx() :: Winsock
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
Sounds like a buffer problem. You sure your buffer class is working right?
Creation is an act of sheer will
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
Again, the problem is still that the receiving process never receives the data.
Kuphryn
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![](smile.gif)
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.
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
![](smile.gif)
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
![](smile.gif)
Creation is an act of sheer will
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement