Jump to content
  • Advertisement

Archived

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

bower12345

Multiple Users and Asynchronous Sockets

This topic is 5309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, Just a quick question. Currently working on some type of decently large scale instant messaging program. But I''m damn confused. I understand the basics. Sending, receiving, accepting, etc..but, should I be say declaring a new object for each user online which holds the socket handle and other various information I may need? And then possibly store this list of objects in a linked list? Also, when the server receives an FD_READ message, how do I know which user, or socket, it was received from? Thanks, Mike

Share this post


Link to post
Share on other sites
Advertisement
Thanks SiCrane...that was what I was looking for. Can I use wParam directly in a recv() call or do I have to explicitly assign it and cast it to a SOCKET type?

Thanks,
Mike

Share this post


Link to post
Share on other sites
You should be use it directly. (Though putting in a cast might be a good idea as a sort of comment.)

Share this post


Link to post
Share on other sites
I wrote a server that when it accepts a new connection it automatically creates a new user object. It then assigned a userID to each object as it was created and used the users socket as the value of the id. It also recieved the users specific object data using recvfrom() and copied the values to the objects variables. The objects also had a address struct in them that was filled with the address info captured by the recvfrom() method. Then it put the object in a linked list.

Also when using FD_SET you can use select() and have it select the sockets that are ready to be read. When you go through the list of all the sockets ready to be read they will contain the socket number telling you whos id number (using method above) sent the message.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!