Note that there are some explanatory texts on larger screens.

plurals
  1. POTCP Echo on different adapter
    primarykey
    data
    text
    <p>I'm trying to write a program for a computer with 2 network adapters (Private and Public) that echoes data received on Private to Public and vice versa. I only need it to listen on two specific ports, and more specifically, it should open a socket server on Private and a socket client on Public.</p> <p>The computer's IP address on Public is 192.168.1.21 and its IP address on Private is 172.16.13.1, so I thought something like this would work:</p> <pre><code>IPEndPoint privateEndpoint1 = new IPEndPoint(IPAddress.Parse("172.16.13.1"), port1); IPEndPoint privateEndpoint2 = new IPEndPoint(IPAddress.Parse("172.16.13.1"), port2); IPEndPoint publicEndpoint1 = new IPEndPoint(IPAddress.Parse("192.168.1.21"), port1); IPEndPoint publicEndpoint2 = new IPEndPoint(IPAddress.Parse("192.168.1.21"), port2); TcpListener priList1 = new TcpListener(privateEndpoint1); TcpListener priList2 = new TcpListener(privateEndpoint2); TcpClient pubCli1 = new TcpClient(publicEndpoint1); //Error here TcpClient pubCli2 = new TcpClient(publicEndpoint2); </code></pre> <p>I then get the streams and do the actual echoing.</p> <p>The problem is that I get an error on the line that I marked:</p> <blockquote> <p>Only one usage of each socket address (protocol/network address/port) is normally permitted</p> </blockquote> <p>It seems from the error that the <code>IPEndPoint</code> constructor is not differentiating between the two IP addresses and the two network adapters. I've looked into using normal <code>Socket</code>s instead of <code>TcpClient</code>s, but that didn't seem to change anything.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload