Archived

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

Gaiiden

Async Socket Problems

Recommended Posts

Gaiiden    5710
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" ==============================

Share this post


Link to post
Share on other sites
JonStelly    127
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...

Share this post


Link to post
Share on other sites
Carbon    122
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

Share this post


Link to post
Share on other sites
Gaiiden    5710
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"
==============================

Share this post


Link to post
Share on other sites