开发者

.net Sockets Basic Discussion

开发者 https://www.devze.com 2023-03-16 06:31 出处:网络
I have never played with .net sockets. I did a couple of things with winsock back in the day. The time has however come to make use of some comms so I am brushing up on .net sockets.

I have never played with .net sockets. I did a couple of things with winsock back in the day. The time has however come to make use of some comms so I am brushing up on .net sockets.

Basically, it seems as tho most examples / implementations use the client server architecture where both IP addesses are known. I want my "server" side to not have to know which IP it is going to get a connection from, but discover it when the connection is made. I.e. I will have multiple cl开发者_StackOverflow社区ients communicating with one server, of which the client ip's will be dynamic.

What is the basic implementation for this type of setup.

Thanks in advance


In usual scenario, client find the server and connect to it and the server accepts the connection. It's pretty straight forward.

For a connectionless implementation, you can use UdpClient class This article will help you to implement a basic TCP/IP or UDP application


Have a look at the TcpListener class, you just have to bind to a port on a local address and accept calls from any address.

0

精彩评论

暂无评论...
验证码 换一张
取 消