Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I wrote a server program which able to connect to multiple clients getting data from there and responds correctly, but i want to send request string from 1 client to other client which has fix ip adrress.

(Say 192.168.1.7 and 192.168.1.5 are two clients connected to sever i will get string from first client and need to send this string to another client, the ip of another client is fixed by setting in router.).How could i do this?

THanks.
Posted
Comments
[no name] 30-Jul-15 0:51am    
Presumably, you would do that the exact same way that you have already done it. You say that you already wrote code that does this, why is this a problem all of a sudden? Why do you think reposting this without any additional information or effort is going to get you any different answers than you already have?

1 solution

If I get you correctly, you're trying to make your client to be able to talk to each other, that's basically a chat application.

At present all your clients can communicate with server, but not with each other, and, that's your problem statement. Am I correct?

Assuming I am correct ;), you need to ensure your if client C1 wants to send a message to another client C2 then, first C1 sends a message to server S and tells it that this message is for client C2, then server sends this message to client C2 i.e. C1 => S => C2
 
Share this answer
 
Comments
Member 11543226 30-Jul-15 2:04am    
That exactly what i mean to say how server will identify that this message for which client amongst all connected clients. how to put that condition by specifying ip. i.e. I want to write code lines which says "if the client (ip spec) is connected then send data"
himanshu agarwal 30-Jul-15 2:13am    
You can put that information in the message body, the server can then parse this information from there. i.e.

C1 should send something like {"Receiver:"C2", "ReceiverIP":"a.b.c.d", "Message":"Hello, I am C1"}

then S can parse Receiver information and send the message to C2

{"Sender": "C1", "SenderIP": "1.2.3.4", "Message":"Hello, I am C1"}

Upon receiving this the client can parse the message and determine who sent the message and what is the message.

You may come up with a better architecture.
Member 11543226 30-Jul-15 3:11am    
Actually device is first client in my case it cannot tells server to send this to client2 . only server have to send data which is in string format to client2 ip.
himanshu agarwal 30-Jul-15 4:11am    
I did not get your point here, out of multiple clients that connect to server, if a client does not specify whom to send data, how will sever determine that? You need to tell this to server somehow or build that logic in server that will hardwire C1 with C2.
Member 11543226 30-Jul-15 4:59am    
server getting data from one client and again server will decide where to send this data. not a client .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900