vista server not accepting connetions

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hi,
I have some code that sets up an asynchronous server. It is working
fine on my XP machines but I can't get it to work on Vista.
Actually, it "works: in that it runs but when I try to connect via
telnet I get nothing. I have tried opening up the port and also
turned off the firewall. Neither seems to work and it won't accept
conections. Does anyone know of anything else I should do?

Thanks,,
Bob

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);

// Create the socket, bind it, and start listening
_serverSocket = new
Socket(myEndpoint.Address.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
_serverSocket.Bind(myEndpoint);

_serverSocket.Listen((int)SocketOptionName.MaxConnections);
 
Hi

Under what user your vista code runs?
I think it's a Vista related problem, so you are going to be better anwered
in a Vista's NG
 
Hi

Under what user your vista code runs?
I think it's a Vista related problem, so you are going to be better anwered
in a Vista's NG


Hi,
I have some code that sets up an asynchronous server. It is working
fine on my XP machines but I can't get it to work on Vista.
Actually, it "works: in that it runs but when I try to connect via
telnet I get nothing. I have tried opening up the port and also
turned off the firewall. Neither seems to work and it won't accept
conections. Does anyone know of anything else I should do?
Thanks,,
Bob

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);
// Create the socket, bind it, and start listening
_serverSocket = new
Socket(myEndpoint.Address.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
_serverSocket.Bind(myEndpoint);
_serverSocket.Listen((int)SocketOptionName.MaxConnections);

Good point. I have tried both an administrator user and a standard
user.
 
Under what user your vista code runs?
I think it's a Vista related problem, so you are going to be better anwered
in a Vista's NG
Hi,
I have some code that sets up an asynchronous server. It is working
fine on my XP machines but I can't get it to work on Vista.
Actually, it "works: in that it runs but when I try to connect via
telnet I get nothing. I have tried opening up the port and also
turned off the firewall. Neither seems to work and it won't accept
conections. Does anyone know of anything else I should do?
Thanks,,
Bob
IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);
// Create the socket, bind it, and start listening
_serverSocket = new
Socket(myEndpoint.Address.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
_serverSocket.Bind(myEndpoint);
_serverSocket.Listen((int)SocketOptionName.MaxConnections);

Good point. I have tried both an administrator user and a standard
user.

I think I figured out the problem. I think has to do with Vista
implementing ipv6 addresses. I was using the following code:

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);

however, the localMachineInfo.AddressList on my vista computer had a
length of 3 compared to 1 on my XP machines. The address that I was
trying to connect to (the old ipv4 version like 192.168.1.1) is the
last entry on vista. Accordingly, when I modify the code to:

IPEndPoint myEndpoint = new IPEndPoint(

localMachineInfo.AddressList[localMachineInfo.AddressList.Length-1],
_port);

it seems to work.

Thanks,
Bob
 
Bob said:
Under what user your vista code runs?
I think it's a Vista related problem, so you are going to be better
anwered
in a Vista's NG

Hi,
I have some code that sets up an asynchronous server. It is working
fine on my XP machines but I can't get it to work on Vista.
Actually, it "works: in that it runs but when I try to connect via
telnet I get nothing. I have tried opening up the port and also
turned off the firewall. Neither seems to work and it won't accept
conections. Does anyone know of anything else I should do?
Thanks,,
Bob

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);
// Create the socket, bind it, and start listening
_serverSocket = new
Socket(myEndpoint.Address.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
_serverSocket.Bind(myEndpoint);
_serverSocket.Listen((int)SocketOptionName.MaxConnections);

Good point. I have tried both an administrator user and a standard
user.

I think I figured out the problem. I think has to do with Vista
implementing ipv6 addresses. I was using the following code:

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);

however, the localMachineInfo.AddressList on my vista computer had a
length of 3 compared to 1 on my XP machines. The address that I was
trying to connect to (the old ipv4 version like 192.168.1.1) is the
last entry on vista. Accordingly, when I modify the code to:

IPEndPoint myEndpoint = new IPEndPoint(

localMachineInfo.AddressList[localMachineInfo.AddressList.Length-1],
_port);

it seems to work.

Thanks,
Bob



There is no guranatee that the IPV4 entry is at a fixed position in the
list, so this is bound to fail. You have to enumerate the list and check the
address family you want your endpoint to bind to.
Something like this will do:

IPHostEntry localMachineInfo Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in localMachineInfo .AddressList)
{
if((int)ip.AddressFamily == (int)ProtocolFamily.InterNetwork)
{
IPEndPoint myEndpoint = new IPEndPoint(ip, _port);
.....


Willy.
 
Awesome, thanks!

Bob said:
On May 1, 12:44 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA



laceupsolutions.com> wrote:
Hi

Under what user your vista code runs?
I think it's a Vista related problem, so you are going to be better
anwered
in a Vista's NG



Hi,
I have some code that sets up an asynchronous server. It is working
fine on my XP machines but I can't get it to work on Vista.
Actually, it "works: in that it runs but when I try to connect via
telnet I get nothing. I have tried opening up the port and also
turned off the firewall. Neither seems to work and it won't accept
conections. Does anyone know of anything else I should do?

Thanks,,
Bob

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);

// Create the socket, bind it, and start listening
_serverSocket = new
Socket(myEndpoint.Address.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
_serverSocket.Bind(myEndpoint);

_serverSocket.Listen((int)SocketOptionName.MaxConnections);

Good point. I have tried both an administrator user and a standard
user.

I think I figured out the problem. I think has to do with Vista
implementing ipv6 addresses. I was using the following code:

IPHostEntry localMachineInfo =
Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint myEndpoint = new IPEndPoint(
localMachineInfo.AddressList[0], _port);

however, the localMachineInfo.AddressList on my vista computer had a
length of 3 compared to 1 on my XP machines. The address that I was
trying to connect to (the old ipv4 version like 192.168.1.1) is the
last entry on vista. Accordingly, when I modify the code to:

IPEndPoint myEndpoint = new IPEndPoint(

localMachineInfo.AddressList[localMachineInfo.AddressList.Length-1],
_port);

it seems to work.

Thanks,
Bob



There is no guranatee that the IPV4 entry is at a fixed position in the
list, so this is bound to fail. You have to enumerate the list and check the
address family you want your endpoint to bind to.
Something like this will do:

IPHostEntry localMachineInfo Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in localMachineInfo .AddressList)
{
if((int)ip.AddressFamily == (int)ProtocolFamily.InterNetwork)
{
IPEndPoint myEndpoint = new IPEndPoint(ip, _port);
.....


Willy.
 

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

Back
Top