0

Hello,

I have two applications; a server and a client which use simple TCP Sockets to connect to each other and send the data.

The only problem I have is that I am struggling to associate usernames with the accepted sockets on the server. The server is able to accept and hold multiple socket connections in order for multi-user chat and I have set up a simple string list ready for the usernames but since I am unable to find any socket IDs or such-like, I can't find a way to associate a name with a socket.

I have looked in to socket connected listener or w/e, but even then, I am unable to send username data with the connect method.

Any help is appreciated,
Thanks.

3
Contributors
3
Replies
14
Views
3 Years
Discussion Span
Last Post by Ketsuekiame
1

can't find a way to associate a name with a socket

I don't think you can. Just send the username as the first data.

0

Ok. I was going to do that as a last resort since multiple people might connect at once and mix up the names. Thanks anyway.

1

Ok. I was going to do that as a last resort since multiple people might connect at once and mix up the names. Thanks anyway.

You can't. Data comes down each socket from a specific client (unless you're using Broadcast). So if you keep that socket in a particular method that expects a certain "Initialisation" data, then there's no chance of mixing names up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.