我如何在同一端口上拥有多个单独的 NetworkStream?
我正在制作一个服务器客户端应用程序..
我想知道是否可以仅对所有端口使用一个端口,而不是对它们的每个端口使用(绑定、监听、接受).. 因为在我的应用程序中.. 我只想连接一次.. 并且连接3次似乎很荒谬..如果我想在同一个端口上连接(聊天、命令、文件传输)..并且如果不可能的话,我如何在单独的NetworkStream上拥有更多的网络流..最好的结构是什么
我对所有这些都使用 tcp 协议..希望我解决了我的问题..提前感谢:)
im making a Server-Client application..
i was wondering if it is possible to use only one port for all of them rather than (bind,listen,accept) for each port of them .. because in my application .. i want to connect once only .. and it seems ridiculous to connect 3 times .. how do i have a more than on separate NetworkStream if i want to connect (chat,commands,file-transfer) on the same port .. and if it's not possible.. what's the best structure to do that
im using tcp protocol for all of them.. hope i cleared my question .. thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有可能,您不需要单独的 NetworkDtream,但您需要区分不同的资源类型,这意味着您只需在 ONE NetworkStream 中发送这 3 种类型的资源,您可以定义一些标志来区分它们,并且它们会进行不同的处理。
尽管如此,我认为你应该有一个额外的端口来传输文件,命令和聊天很短,而文件数据很大
It's possible, you don't need to have seperate NetworkDtream but you need to distinguish different resource type, which means, you just send that 3 types of resources in ONE NetworkStream and you can define some flags to distinguish them and them make different proceed.
Even though, I think you should have a extra port to transfer files , commands and chats were short while files data was quite big