1

I'm looking for a good example of a simple TCP server/client that can deliver messages from one client to another. I have looked at many examples, but I can only find really complex ones, or one's where only one client talks to the server and back, and not to each other.

1
  • It would be best if you could try something simple, then post more specific questions once you've tried something. Commented May 10, 2012 at 3:05

1 Answer 1

3

See selectserver.c at http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html. Clients are defined earlier on the page and server seems pretty easy to expand.

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

2 Comments

That one is good but it doesn't have an example of 2 clients communicating to each other.
@JonBlake That's because it's impossible with TCP sockets. You need one side to create a listening socket ("be a server") and the other to connect ("be a client"). For connectionless transport look into UDP. Read section 2 in Beej's guide for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.