Async Socket Problems
I''m not quite getting Async sockets here. Rather than waste time experimenting, I thought I''d ask all you people. So here goes.
What I don''t get is how it''s all set up. From what I''ve read, if you call a conect() function, you will get a message (FD_CONNECT) when the server accepts the connection. Now, after connect() has been called, does the program move on? Since it''s non-blocking might it return WSA_WOULDBLOCK (or something like that) as an error? So wouldn''t I need a loop to keep the program from getting ahead of itself (after connect you send data, but you can''t if you aren''t connected)?
Basically I just don''t get how to structure the program using the messages. When I get the FD_READ message, to I call the recv() function right then? I know it''s a lot to explain but if you could just sum it up with an example.... thanks.
==============================
"Need more eeenput..."
- #5, "Short Circuit"
==============================
Drew Sikora
Executive Producer
GameDev.net
No, you shouldn''t loop polling for completion. When dealing with Async Sockets, think of them as Windows. You respond to events on them as you do to mouse clicks etc...
JonStelly put it quite well. You respond to the events in the same way as mouse clicks etc... If you want a really simple example of using ASyncSocket, tell me and I can send you a program I made a while back, in which one program acts as the server, the other as the client, and then once the connection is made, the two programs can send each other messages back and forth.
-Carbon
-Carbon
-Carbon
yeah, Carbon, would you mind doing that? That would help me out a lot. Promise not to use any of your code
==============================
"Need more eeenput..."
- #5, "Short Circuit"
==============================

==============================
"Need more eeenput..."
- #5, "Short Circuit"
==============================
Drew Sikora
Executive Producer
GameDev.net
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement