Sunday, 2 April 2017

C# TcpClient use Ipv4 only

I am connected to a node.js server with a C# TcpClient:

 TcpClient tcpClient = new TcpClient(AddressFamily.InterNetwork);
           tcpClient.Connect("192.168.2.110", 8000);

Node.js code:

var connectedClients = [];
var tcp_server = net.createServer(function (socket) {

   var newClient = socket.address();
   connectedClients[newClient.address].push(newClient);
});

tcp_server.listen(8000, function () {
  console.log("tcp server listening");
});

However the socket.adress is IPv6, but I need it in IPv4 format. Some simple solution to force the TcpClient using IPv4? AddressFamily.InterNetwork didn't work.



via flowest

No comments:

Post a Comment