Answer the question
In order to leave comments, you need to log in
System.Net.Sockets.TcpClient find out client ip address?
Highly simplified code:
TcpListener listener = new TcpListener(IPAddress.Any, 30000);
listener.Start();
TcpClient client = listener.AcceptTcpClient();
Console.WriteLine(client.Client.RemoteEndPoint);
listener.Stop();
Console.ReadLine();
import SocketServer
class MyTCPHandler(SocketServer.BaseRequestHandler):
def handle(self):
print self.client_address[0]
if __name__ == "__main__":
HOST, PORT = "0.0.0.0", 30000
server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
server.serve_forever()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question