简体   繁体   English

C#套接字:客户端连接时获取服务器

[英]c# socket: get server when client connects

i have a Server socket using an async functions to allow a client socket to connect. 我有一个使用异步功能的服务器套接字,以允许客户端套接字连接。 And when i call Socket.EndAccept() it returns a copy of the client Socket, 当我调用Socket.EndAccept()时,它返回客户端Socket的副本,

i'd like some way for the client socket connecting to get a copy of the Server socket 我想以某种方式连接客户端套接字以获取服务器套接字的副本

is this possible? 这可能吗?

EDIT: question was rather forumlated weird, sorry, found a solution to the problem though. 编辑:问题是相当古怪的论坛,很抱歉,虽然找到了解决问题的方法。

The problem was that when i tried to send reply back to the client i used the server socket instead of the socket returned from Socket.endAccept() 问题是,当我尝试将答复发送回客户端时,我使用服务器套接字而不是从Socket.endAccept()返回的套接字。

Thank you 谢谢

ehh? 嗯? You just used it when calling Socket.EndAccept() ? 您刚刚在调用Socket.EndAccept()时使用了它吗?

Socket is the server socket. Socket是服务器套接字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM