DumbestGuyOnSaturn
DumbestGuyOnSaturn

Reputation: 51

VB.NET Server Does Not Receive Connection Requests from Remote Clients

VB.NET Server Does Not Receive Connection Requests from Remote Clients

A VB.NET server application does not see connection requests from another client on the network (i.e. with a different IP address). However, it does see connection requests from the client application running on the same computer as the server.

The listening socket is created with the following parameters

System.Net.Sockets.AddressFamily.InterNetwork

System.Net.Sockets.SocketType.Stream

System.Net.Sockets.ProtocolType.IP

We have experimented with the preceding without success.

The endpoint to which the listening socket is bound specifies the local IP address and a specific port number.

The wait-for-connection code is textbook asynchronous:

thelistener.Listen(10)
thelistener.BeginAccept(New System.AsyncCallback(AddressOf targetofaccept), thelistener)

If the client that attempts connection is on the same computer as the listener, then targetofaccept is run successfully. If the client that attempts connection is on some other computer on the network, then targetofaccept is not run.

The behavior occurs for any other client on the network (i.e., not just one).

Thinking that there was some firewall issue, we created VB6 servers and clients using the same addresses and ports. The VB6 server will receive connection requests regardless of the client system.

There is no other issue with communication between clients and the server, as far as we can see. The network architecture has not been modified for a number of years.

We are debugging the code as a VB.NET console application.

Any tips on how to diagnose appreciated.

Upvotes: 0

Views: 415

Answers (2)

DumbestGuyOnSaturn
DumbestGuyOnSaturn

Reputation: 51

Thank you.

Issue WAS firewall. Fixed by finding exact location of the IDE (devenv.exe), opening "Windows Firewall" in the control panel, selecting "Allow a program or feature through firewall", selecting "Allow another program...", browsing to the exact location and selecting the executable, then ensuring "Home/Work (Private)" column is checked for that "Name".

Upvotes: 0

Visual Vincent
Visual Vincent

Reputation: 18320

Before calling Listen() you need to bind your listener socket to the address 0.0.0.0 (in .NET IPAddress.Any) so that it listens to connections from any IP address.

This can be done using the Socket.Bind() method:

Dim listenerEndpoint As New IPEndPoint(IPAddress.Any, <your port>)
thelistener.Bind(listenerEndpoint)

thelistener.Listen(10)

Upvotes: 0

Related Questions