如何使用端口从服务器向客户端发送消息? [英] How I can send message from server to client using the port?

查看:268
本文介绍了如何使用端口从服务器向客户端发送消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tcplistener在端口上侦听请求。当请求从客户端进来时,我想知道发出请求的客户端ip。问题是:服务器和所有客户端采取相同的Ip

因此我决定通过端口从服务器向客户端发送按摩...我在谷歌搜索了很多但是我不知道我怎么能使用端口从服务器向客户端发送消息?所以身体能帮助我吗?



我尝试过的事情:



我尝试上面的问题...我搜索了很多但不知道如何使用端口从服务器发送消息到客户端

I am using Tcplistener to listen on a port for requests. When the requests come in from the client I want to know the client ip making the request. the problem is : the server and all client take the same Ip
so I decided to send massage from server to client by port ... I search a lot on google But I did not knew how I can send message from server to client using the port ? so can any body help me ?

What I have tried:

my try in my quetion above ... I search alot but did not knew How I can send message from server to client using the port

推荐答案

它的工作方式客户端和服务器都有一个IP地址。如果两者都在同一台机器上运行,它可能会是相同的。 服务由端口号定义。 HTTP为80,SMTP为21等。



您必须同时进行TCP通信,而且 - 您使用端口8080(这是一种常见的选择)对于HTTP代理)。



这就是你所拥有的,IPAddress - 谁,端口 - 做什么。如果这些信息不够,那么你必须在TCP堆栈上面自己的角色。
The way it works is both client and server have an IP address. If both run on the same machine it will likely be the same. The 'service' is defined by the port number. 80 for HTTP, 21 for SMTP etc.

You have to have both for TCP communication, and you do - you're using port 8080 (which is a common choice for an HTTP proxy).

That's all you have, IPAddress - Who, Port - Doing What. If that information is not enough then you'll have to role your own above the TCP stack.


这篇关于如何使用端口从服务器向客户端发送消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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