Archived

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

bower12345

Multiple Users and Asynchronous Sockets

Recommended Posts

bower12345    122
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
bower12345    122
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
SiCrane    11839
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
Pip    122
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