简体   繁体   English

Socket.Bind是否对套接字编程的每种情况都是必需的?

[英]Does Socket.Bind be necessary for every situation about Socket programming?

Does Socket.Bind be necessary for every situation? 在每种情况下都需要Socket.Bind吗? If no, what are the situation in which Socket.Bind must be used? 如果否,在什么情况下必须使用Socket.Bind? Any help? 有什么帮助吗? Thanks. 谢谢。

Every situation? 每种情况? No. It is required for servers, they need to call Listen() and that's meaningless unless Socket knows what IP-address to listen on. 否。这是服务器所必需的,它们需要调用Listen(),除非套接字知道要监听的IP地址,否则这是没有意义的。 Clients only have to call Connect(), that takes an IP-address. 客户端只需调用带有IP地址的Connect()。

The TcpListener class hides the Bind() call for you. TcpListener类为您隐藏Bind()调用。

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

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