New Winsock Asyncsocket Code / Tutorial

Started by
2 comments, last by -BacksideSnap- 23 years, 8 months ago
If anyone is interested, I put up code for an Asynchronous server using winsock2. You can check it out on my site under the programming section. www.binaryvenom.com There''s a server there as well as a simple client to compliment it. -BacksideSnap-
Advertisement
i downloaded it and it looked good. But if you can put into the code for the server to send the message back to the client (or all clients) for them to display in there window then that would help me out alot.
I tried to do this myself but I couldnt get the client to recognize the FD_READ event. Any help ?


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Since this is sample code you should try to make it idiot proof. With that in mind I''ve got two issues.

Is there some reason you''re forcing Winsock 2.2? For what you''re trying to do 2.0 should be fine and you''re less likely to break somebody who isn''t on the bleeding edge of all their updates. Maybe even 1.X would work, I don''t know if the async stuff was in there then.

Telling people to change the IP address to be the one for thier computer isn''t going to work - they''ll cut & paste code and won''t pay attention. Since all you''re doing is looping back to the same app use the loopback address "127.0.0.1" or better yet INADDR_LOOPBACK. Maybe go the extra step of doing inet_addr/gethostbyname to make it really robust for only a couple lines of code.

-Mike
Mike: You''re right, I could have idiot proofed it a little. I don''t want to put the loopback in there because I think it will confuse people, and if they''re just cutting and pasting I don''t care if it works anyways. As for the version, if they have Win 98, NT or 2000 then they have version 2.2

ncsu: I''m not sure exactly what your problem is. Are you making the client asynchronous? In order to send back to all the clients, you''ll have to make a client list and send to each and every client on the list if you use TCP. You can also go for UDP and do a multicast instead.

-BacksideSnap-

This topic is closed to new replies.

Advertisement