Service not working in Network?

G

Guest

hi all,

I have written a C# Service which is a Server accepting Clients,It is
working fine when i connect from localhost but when i connect from any other
machine to my machine , the service is not working, the Service is in
"Network Service".....i even tried "Local System" and also "Local Service"
but the end result is , it is working only for Localhost connections and not
for Remote Connections...

the code for server is as follows..

////////////************Server Code starts here**********//////////////////
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener listener = new TcpListener(ipAddress,portNum);
try
{
listener.Start();
TcpClient handler = listener.AcceptTcpClient();
////extra things done here
}
////////////************Server Code starts here**********//////////////////

but the remote connections are not getting connected.......why so?

with regards,
C.C.Chakkaradeep
 
W

Willy Denoyette [MVP]

Chakkaradeep said:
hi all,

I have written a C# Service which is a Server accepting Clients,It is
working fine when i connect from localhost but when i connect from any
other
machine to my machine , the service is not working, the Service is in
"Network Service".....i even tried "Local System" and also "Local Service"
but the end result is , it is working only for Localhost connections and
not
for Remote Connections...

the code for server is as follows..

////////////************Server Code starts
here**********//////////////////
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener listener = new TcpListener(ipAddress,portNum);
try
{
listener.Start();
TcpClient handler = listener.AcceptTcpClient();
////extra things done here
}
////////////************Server Code starts
here**********//////////////////

but the remote connections are not getting connected.......why so?

How would you like your clients to connect if you bind your listener to
'localhost' which resolves to 127.0.0.1?
You have to use your real host name, not the loopback address.

Willy.
 
G

Guest

hi willy,

this was really a silly but a BIG mistake........thanks for the reply....

with regards,
C.C.Chakkaradeep

Willy Denoyette said:
Chakkaradeep said:
hi all,

I have written a C# Service which is a Server accepting Clients,It is
working fine when i connect from localhost but when i connect from any
other
machine to my machine , the service is not working, the Service is in
"Network Service".....i even tried "Local System" and also "Local Service"
but the end result is , it is working only for Localhost connections and
not
for Remote Connections...

the code for server is as follows..

////////////************Server Code starts
here**********//////////////////
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener listener = new TcpListener(ipAddress,portNum);
try
{
listener.Start();
TcpClient handler = listener.AcceptTcpClient();
////extra things done here
}
////////////************Server Code starts
here**********//////////////////

but the remote connections are not getting connected.......why so?

How would you like your clients to connect if you bind your listener to
'localhost' which resolves to 127.0.0.1?
You have to use your real host name, not the loopback address.

Willy.
 
G

Guest

hi,

my service is working fine..if i connect from the same machine to my server
which is also running in the same machine, there s no any delay but the same
if i connect to my service from anyother remote client, there s delay,it is
taking minimum 60 seconds.....is this my network problem r is that i have
fine tune somewhere n my Server....

with regards,
C.C.Chakkaradeep

Chakkaradeep said:
hi willy,

this was really a silly but a BIG mistake........thanks for the reply....

with regards,
C.C.Chakkaradeep

Willy Denoyette said:
Chakkaradeep said:
hi all,

I have written a C# Service which is a Server accepting Clients,It is
working fine when i connect from localhost but when i connect from any
other
machine to my machine , the service is not working, the Service is in
"Network Service".....i even tried "Local System" and also "Local Service"
but the end result is , it is working only for Localhost connections and
not
for Remote Connections...

the code for server is as follows..

////////////************Server Code starts
here**********//////////////////
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener listener = new TcpListener(ipAddress,portNum);
try
{
listener.Start();
TcpClient handler = listener.AcceptTcpClient();
////extra things done here
}
////////////************Server Code starts
here**********//////////////////

but the remote connections are not getting connected.......why so?

How would you like your clients to connect if you bind your listener to
'localhost' which resolves to 127.0.0.1?
You have to use your real host name, not the loopback address.

Willy.
 
W

Willy Denoyette [MVP]

Chakkaradeep said:
hi,

my service is working fine..if i connect from the same machine to my
server
which is also running in the same machine, there s no any delay but the
same
if i connect to my service from anyother remote client, there s delay,it
is
taking minimum 60 seconds.....is this my network problem r is that i have
fine tune somewhere n my Server....

with regards,
C.C.Chakkaradeep


I wouldn't know, but I guess it's more likely a bug than a network problem.
I would try to telnet with your service (telnet servername port), to see
wheter it's a server or a client issue.

Willy.
 
G

Guest

Hi Willy,

i tried connecting by writing a Client program in Linux and connecting to my
server...within no time the Client connected..!!!!...but wht abt c#
Client??...is this s C# Client program??....i used TCPClient for writing
Client program...

with regards,
C.C.Chakkaradeep
 
W

Willy Denoyette [MVP]

Chakkaradeep said:
Hi Willy,

i tried connecting by writing a Client program in Linux and connecting to
my
server...within no time the Client connected..!!!!...but wht abt c#
Client??...is this s C# Client program??....i used TCPClient for writing
Client program...

There must be something wrong in your C# client, step through it in the
debugger and look where it waits.

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

Top