Fredrik Wigårde
Fredrik Wigårde

Reputation: 71

Client-Client communication through a server

I'm trying to figure out how to do a very small chat program where I have a server and several clients, lets say 3, the server should be the middleman in all the communication and all message should be passed to it before passing it forward to the right client.

Now I'm quite new at this so all I got is a client that can connect to the server using TcpListener and Socket. The client can then send a message to the server and the server can reply. Essentially what I'm asking is how can I connect 3 clients at once, and how I can i destinguish the difference between them, so I know which client to forward my message to.

This is what I got so far: https://gist.github.com/4555536

Also, how do I handle when I want to send several messages in a row without having to send back an acknwoledgement ? I mostly do games where I got an update method that can handle this for me.

Edit: How do I do it localy ? I know I can use IP adresses otherwise.

Best Regards, Fredrik

Upvotes: 0

Views: 499

Answers (1)

Christian Graf
Christian Graf

Reputation: 406

You could identify the connecting client by its IP

Upvotes: 1

Related Questions