コンピューターでサーバーとクライアントを使用して非同期ソケットを試しました(1 サーバーと 2 クライアント):
server ip = 0.0.0.0
client 1 ip = 127.0.0.1
client 2 ip = 127.0.0.2
サーバー側では、サーバーが最初のクライアントから最初の接続要求を受信すると、最初のクライアント ソケットを ArrayList に格納します。次のコードでは、クライアントの IP は 127.0.0.1 です。
TryCast (tcp.Client.RemoteEndPoint, IPEndPoint).Address
サーバーが 2 番目のクライアントから 2 番目の接続要求を受信すると、クライアントの IP は 127.0.0.1 ですが、127.0.0.2 ではありません。
上記のコードを RemoteEndPoint から LocalEndPoint に変更すると、出力は正しくなります。サーバー側のRemoteEndPointがクライアント IPを表さないのはなぜですか?
から
TryCast (tcp.Client.RemoteEndPoint, IPEndPoint).Address '(second client ip not correct)
に
TryCast (tcp.Client.LocalEndPoint, IPEndPoint).Address ' (correct result)
ありがとう。