🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Async Socket Creation

Started by
4 comments, last by Depth 23 years, 1 month ago
Ok .. let me see if I can explain this without confusing the hell out of everyone... I''m working on a Winsock project to connect to a mail server(POP3). First I create the socket as TCP, then I call WSAAsyncSelect with FD_READ|FD_WRUTE|FD_CONNECT|FD_CLOSE. When I FIRST connect to the server, I will get the "+ OK Welcome to server" message. Anytime after that, I can send data, but NOT receive anything. The FD_READ event just isn''t being triggered. If anyone can help - much appreciated. Depth
Advertisement
could you post the code?
Which messages exactly are firing? Are you making only ONE ASyncSelect call? Are you sure you''re reading all the data from the socket?

Why are you using FD_WRITE?
"Are you making only ONE ASyncSelect call? "

Yes I am, before I connect with the socket, I''m emitting this:
WSAAsyncSelect(sck,hwnd,WM_ONSOCKET,FD_CONNECT|FD_READ|
FD_WRITE|FD_CLOSE)


and as far as using FD_WRITE, I''m using it simply because I thought I was supposed to..

Does this call look incorrect?

Here''s the order of the firing and what is and ISN''T firing:

First I connect. On connect I receive a FD_READ, FD_WRITE, FD_CONNECT.

The incoming data is "+OK, WELCOME TO BLAHBLAH"

Then after that, I will send "USER x" then "PASS x"... then I receive a FD_CLOSE. I''m never getting the message "Invalid username/password ...blah..." that I KNOW I SHOULD be getting. ( tested with another program ) ...

Thanks for your reply.
Well, without seeing your code it''s hard to tell... However, some general advice:

Don''t use FD_WRITE. It''s unneccesary in this context. In fact, I can''t really think offhand of a place it would be necessary. It is not a notification in the sense that FD_READ and FD_CONNECT are. (look at MSDN for more regarding FD_WRITE) The purpose of ASyncSelect is to notify the program when a particular action takes place... in this case you are interested in knowing when is the appropriate time to READ from the socket. Your program already knows when to write and when it is connected to the remote host, since you are coding the client. I believe FD_CONNECT is really only appropriate when you have a server waiting to connect (but I could be wrong). And in this case what I do is make one call to ASyncSelect() with FD_CONNECT and when that happens then make a new socket to accept the connection and use FD_READ with that socket.

Another suggestion... create both the client and the server so that you can see exactly what is going on, on both ends. Perl is an excellent tool for quickly creating socket test apps... I''ve created SMTP and HTTP "servers" in Perl in a matter of minutes.

Cool - lot of new things to try. Thanks for your advice.

This topic is closed to new replies.

Advertisement