Toemsel / Network

C# Network Library
https://push-force.dev
GNU Lesser General Public License v3.0
355 stars 65 forks source link

Cannot communicate withe IPv4 address #82

Closed Nic-Alexander closed 2 years ago

Nic-Alexander commented 2 years ago

I'm really impressed with your tools. I'm not sure if this is the right place for a question like this.

I have set up the demo code, and it works fine if I use my computer's temporary IPv6 address for client and server, but if I set the client and the server to my computer's IPv6 address or its static IPv4 address (e.g. 192.168.1.150), then I get a client timeout error when it tries to create a connection. I can ping the server from the client with any of the 3 addresses.

I can't find an example of setting the serve to an IPv4 address. I have been using

  serverConnectionContainer = ConnectionFactory.CreateServerConnectionContainer(ipv4address, 1234, false);

Do you have any ideas what could be going wrong?

Toemsel commented 2 years ago

is the target port 1234 open on the target machine?

Nic-Alexander commented 2 years ago

Yes, the demo works fine with that port if I use the server's temporary IPv6 address.

Toemsel commented 2 years ago

Are you sure about this code?

serverConnectionContainer = ConnectionFactory.CreateServerConnectionContainer(ipv4address, 1234, false);

The server doesn't need an IP. The client requires to point to the SVR ip. Dont provide the IP and try again. There might be an issue with the TCPListener if you listen on a specified IP's interface.

serverConnectionContainer = ConnectionFactory.CreateServerConnectionContainer(1234, false);

The code above points to IPAddress.Any

Nic-Alexander commented 2 years ago

Ah; that was it! The client now connects on the IPv4 address. Thanks very much.