Socket will not accept connections from remote machines

W

Wayne And Miles

I have created a server application that listens for connections using the
TCPListener class. When I connect to the server using a client on the same
machine as the server, all works as expected. However, when I attempt to
connect to the server application from a client on a remote machine on my
LAN, the connection is refused. I have used Ethereal to confirm that the
request from the client is being received on the server machine. I suspect
that this has something to do with socket or application permissions. Can
anyone point me in the correct direction?

My server application is created using VB.NET 2005 and runs on Windows XP
Home. My client application is running on a Windows XP Professional
machine.

The code to create the listening socket is as follows:

Dim sender As TcpListener = New TcpListener(IPAddress.Parse("127.0.0.1"),
_settings.ClientPort)
Try
sender.Start()
sender.BeginAcceptSocket(AddressOf SenderBeginAcceptEventHandler, sender)
Catch ex As SocketException
MessageBox.Show("Unable to accept connections on port " &
_settings.ClientPort & ".", "Web Proxy", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End Try
 
G

Goran Sliskovic

Wayne And Miles said:
...
The code to create the listening socket is as follows:

Dim sender As TcpListener = New TcpListener(IPAddress.Parse("127.0.0.1"),
_settings.ClientPort)
Try
sender.Start()
....

You are listening only on loopback address, which is not accessible from
outside. Yoe have to listen on external (ethernet) interface, or even
better, on any address (IPAddress.Any - "0.0.0.0"):

New TcpListener(IPAddress.Any, _settings.ClientPort);

Regards,
Goram
 
H

Henning Krause [MVP - Exchange]

Hello,

you are binding to the localhost address.

Try

Dim sender As TcpListener = New TcpListener(IPAddress.Any,
_settings.ClientPort)

Best regards,
Henning Krause
 
W

Wayne

Many thanks. That was exactly the problem.
Henning Krause said:
Hello,

you are binding to the localhost address.

Try

Dim sender As TcpListener = New TcpListener(IPAddress.Any,
_settings.ClientPort)

Best regards,
Henning Krause
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top