PDA

View Full Version : Sending Message From One TCPSocket to Another



zgulser
29th November 2010, 14:47
Hi all,

I have written a simple network program that includes a server and two clients. What I want to do is to establish a connection between those clients.

When I send information from the server to the clients it works OK. But if I try the kind of same thing in a reverse order(from one of the clients to the another client), it doesn't work.

I'm quite fresh in network programming so I couldn't even be sure if I design the correct architecture for the clients to communicate. I mean maybe just two TCPSockets are enough to achieve..Anyways any suggestions could be profoundly helpfull.

King Regards

franz
29th November 2010, 15:52
It kind of depends what you want to achieve.
Direct connection: Clients have to ask server about other client, you can then setup the connection (p2p)
Indirect connection: Clients send to server, server relays to other clients based on some addressing or grouping (irc, icq, msn)

If you want the server out of the equation, the two clients should be able to auto-detect each others presence (you could use a broadcast message at a certain port or use the apple bonjour framework for that, just to name two possibilities). You could of course also just enter an ip address or host name. There are some Qt examples for this type of communication.

zgulser
30th November 2010, 07:54
Hi again,

The indirect connection is the thing then. But the problem is I can't send any to server for other client to take it..I will check the documentation and inform you if a problem rises.

Added after 40 minutes:

Hi,

I have looked and applied some of things written in the docs but it didn't work anyway. As far as I surf in the web, it's a common problem for developers to send data from client to server.