多客户端和单服务器的套接字编程

编程入门 行业动态 更新时间:2024-10-10 06:15:51
本文介绍了多客户端和单服务器的套接字编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要创建一个基于客户端服务器的软件(桌面)。 会有多个客户端使用不同的IP地址,但端口号相同。 eg- 客户端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?

更多推荐

多客户端和单服务器的套接字编程

本文发布于:2023-11-30 22:32:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   服务器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!