如何将数据发送到特定的IP地址? [英] How to send data to perticular ip address?

查看:619
本文介绍了如何将数据发送到特定的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个服务器程序,它能够连接到多个客户端从那里获取数据并正确响应,但我想将请求字符串从1个客户端发送到其他已修复ip adrress的客户端。



(假设192.168.1.7和192.168.1.5是连接到服务器的两个客户端我将从第一个客户端获取字符串并需要将此字符串发送到另一个客户端,即ip通过在路由器中设置来修复另一个客户端。)。我怎么能这样做?



谢谢。

解决方案

如果我找到你,你正试图让你的客户到能够互相交谈,这基本上就是一个聊天应用程序。



目前你所有的客户都可以与服务器通信,但彼此之间没有通信,那就是你的问题陈述。我是否正确?



假设我是正确的;),你需要确保你的客户C1是否想要向另一个客户C2发送消息然后,首先C1发送一个消息到服务器S并告诉它该消息是针对客户端C2的,然后服务器将该消息发送给客户端C2,即C1 => S => C2

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.

解决方案

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


这篇关于如何将数据发送到特定的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆