Reputation:
I am coding a chat application as an intro for me to sockets. I was trying to get the clients and servers IP address and save it to a richtextbox
. I put it into a thread and whenever there is a connection pending, it will accept and get the IP address, but it fails out in debug mode. Please advice. Thank you so much!
Upvotes: 1
Views: 337
Reputation: 560
AcceptTcpClient()
returns the TcpClient
for the incoming connection.
Try this code:
var client = tcpListener.AcceptTcpClient();
var remoteEndPoint = _currentClient.Client.RemoteEndPoint;
Upvotes: 1