0

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

1 Answer 1

1

You could identify the connecting client by its IP

Sign up to request clarification or add additional context in comments.

2 Comments

Well right now I'm trying to do this localy on my own machine only.
Well, what about assigning a random id to every of your software clients and sending this id to the server? Or letting the server asign an unique id to every client that connects for the first time?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.