多客户端和单服务器的套接字编程 [英] Socket Programming for multiple client and single server

查看:85
本文介绍了多客户端和单服务器的套接字编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要创建一个基于客户端服务器的软件(桌面)。



会有多个客户端使用不同的IP地址,但端口号相同。



eg-



< pre lang =text>客户端A有ip:172.21.5.2,端口号:5555
客户端B有ip:172.21.5.3,端口号:5555
客户端C有ip:172.21.5.4 with端口号:5555
客户端D有ip:172.21.5.5,端口号:5555









服务器有 ipddress:172.21.5.1 端口号:5555



现在我需要在服务器A,B,C和D之间创建一个通信链接。



有人可以帮帮我吗?



先谢谢。

:)

解决方案

这是最常见的情况。谷歌有几个很好的例子吗?

从这里开始:使用C#中的套接字 [ ^ ]

但是,由于您没有进一步说明您的申请,这是我建议的最多。

那你到目前为止尝试了什么?

请注意,您不能通过tcp / ip堆栈的设计指定客户端端口。 Ant根本没有任何意义,试图这样做。为什么你认为你需要这个?


Hi,

I need to create a client server based software (desktop).

There would be multiple client with different IP Address, but same port number.

eg-

client A has ip:172.21.5.2 with port number:5555
client B has ip:172.21.5.3 with port number:5555
client C has ip:172.21.5.4 with port number:5555
client D has ip:172.21.5.5 with port number:5555



and

server has ipddress:172.21.5.1 with port number:5555.

Now I need to create a communicate link between client A, B, C and D with the server.

Could someone please help me ?

Thanks in Advance.
:)

解决方案

This is the most common scenario. There are several good examples you could find with google?
Start here: Working with Sockets in C#[^]
But as you have not specified anything further regarding your application, this is much the most I could suggest.
So what have you tried so far?
Please note, that you can not specify client port by design of tcp/ip stack. Ant it makes also no sense at all trying to do so. Why do you think you need this?


这篇关于多客户端和单服务器的套接字编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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