473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Socket error

Jay
I have a socket listener and a test app.
The socket listener app: opens up the port 51296 and listens.
The test app - sends a message on port 51296.
If the listener and test app are on the same box, all is well - everything
works as expected.
But when I move my test app to a remote box: I get the following error:
"no connection could be made because the target machine actively refused it"
--------------------------------------------------
This is the listener code:
IPHostEntry hostEntry = Dns.GetHostEntry(myserver.domain.com);

IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList[0], 51296);

Socket soc =

new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

soc.Connect(ipe);

soc.Send(Encoding.ASCII.GetBytes("some text message"));

soc.Close();

------------------------------------------------------------------------------------------------

I have firewall enabled on the server box (where the listener is running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work.

Any ideas on how to detect where the problem is..?

Thanks much

Jay
Feb 9 '07 #1
11 2861
Definitely sounds like the firewall or some other thing cauing the issue.
You sure no other app is running that port on that machine? did you check
the client is also not blocking that port?

I usually turn off everything, antivirus progs everything (best to not be on
the net when you do this) and all firewalls. Then try, if it works i start
to put them on one by one until it doesn't work. Then fix the app causing
the block.

"Jay" <Ja*@microsoft.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>I have a socket listener and a test app.
The socket listener app: opens up the port 51296 and listens.
The test app - sends a message on port 51296.
If the listener and test app are on the same box, all is well - everything
works as expected.
But when I move my test app to a remote box: I get the following error:
"no connection could be made because the target machine actively refused
it"
--------------------------------------------------
This is the listener code:
IPHostEntry hostEntry = Dns.GetHostEntry(myserver.domain.com);

IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList[0], 51296);

Socket soc =

new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

soc.Connect(ipe);

soc.Send(Encoding.ASCII.GetBytes("some text message"));

soc.Close();

------------------------------------------------------------------------------------------------

I have firewall enabled on the server box (where the listener is running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work.

Any ideas on how to detect where the problem is..?

Thanks much

Jay


Feb 9 '07 #2
Jay
I cannot turn off the firewall. Its set by the corporate group policy.
I have admin previlages to modify, but not turn it off completely.

"PokerMan" <no****@pokercat.co.ukwrote in message
news:uz**************@TK2MSFTNGP06.phx.gbl...
Definitely sounds like the firewall or some other thing cauing the issue.
You sure no other app is running that port on that machine? did you check
the client is also not blocking that port?

I usually turn off everything, antivirus progs everything (best to not be
on the net when you do this) and all firewalls. Then try, if it works i
start to put them on one by one until it doesn't work. Then fix the app
causing the block.

"Jay" <Ja*@microsoft.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>>I have a socket listener and a test app.
The socket listener app: opens up the port 51296 and listens.
The test app - sends a message on port 51296.
If the listener and test app are on the same box, all is well -
everything works as expected.
But when I move my test app to a remote box: I get the following error:
"no connection could be made because the target machine actively refused
it"
--------------------------------------------------
This is the listener code:
IPHostEntry hostEntry = Dns.GetHostEntry(myserver.domain.com);

IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList[0], 51296);

Socket soc =

new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

soc.Connect(ipe);

soc.Send(Encoding.ASCII.GetBytes("some text message"));

soc.Close();

------------------------------------------------------------------------------------------------

I have firewall enabled on the server box (where the listener is
running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work.

Any ideas on how to detect where the problem is..?

Thanks much

Jay



Feb 9 '07 #3
Hi,

"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
|I cannot turn off the firewall. Its set by the corporate group policy.
| I have admin previlages to modify, but not turn it off completel

Well, then how do you expect that the remote client can connect to your
server if there is a firewall?

Either you remove your firewall or at least allow that port to pass through.
--
Ignacio Machin
machin AT laceupsolutions com
Feb 9 '07 #4
Ignacio, at end of his post he says:

"I have firewall enabled on the server box (where the listener is running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work."

My best advice since you cant turn it off is try changing the port number
and see if you have more luck. Sounds like the firewall is the reason
though. Do check if there is anything else blocking that port.

As a check try this, start your app listening.

then open a command prompt and type Netstat -a

This shows all connections. Ensure your app is listening on the port you
mentioned. If it is then try telnet to that port and see if the server lets
that through. I am sure you'll find it doesnt due to the firewall, if it
does then there is a problem with your client end software on how it
connects.

Definitely sounds like an administrative problem not a code one though.

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:eE**************@TK2MSFTNGP06.phx.gbl...
Hi,

"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
|I cannot turn off the firewall. Its set by the corporate group policy.
| I have admin previlages to modify, but not turn it off completel

Well, then how do you expect that the remote client can connect to your
server if there is a firewall?

Either you remove your firewall or at least allow that port to pass
through.
--
Ignacio Machin
machin AT laceupsolutions com


Feb 9 '07 #5
Jay
I am allowing that port to pass through.
But still I cannot see the messages come through.
Are there any tools that I can use to monitor what is happening?

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:eE**************@TK2MSFTNGP06.phx.gbl...
Hi,

"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
|I cannot turn off the firewall. Its set by the corporate group policy.
| I have admin previlages to modify, but not turn it off completel

Well, then how do you expect that the remote client can connect to your
server if there is a firewall?

Either you remove your firewall or at least allow that port to pass
through.
--
Ignacio Machin
machin AT laceupsolutions com


Feb 9 '07 #6
Your code snippet says listener code but it looks more like client code.
Does an nslookup of myserver.domain.com return only one IP address?
Do you know which IP and/or interface AddressList[0] is binding too? Does
the server use similar code to setup the listener? Is it possible it's
binding to an IP that the remote machine does not have a route to? For
example, I have VMWare on my machine so there are 2 virtual adapters that
have private IPs that are not part of our local subnet. If my software
listened on one of those then remote machines would have no way of
connecting to me, but the same client running on my workstation would. Make
sure you are listening on the interface and IP you think you are listening
on.

jim

"Jay" <Ja*@microsoft.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>I have a socket listener and a test app.
The socket listener app: opens up the port 51296 and listens.
The test app - sends a message on port 51296.
If the listener and test app are on the same box, all is well - everything
works as expected.
But when I move my test app to a remote box: I get the following error:
"no connection could be made because the target machine actively refused
it"
--------------------------------------------------
This is the listener code:
IPHostEntry hostEntry = Dns.GetHostEntry(myserver.domain.com);

IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList[0], 51296);

Socket soc =

new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

soc.Connect(ipe);

soc.Send(Encoding.ASCII.GetBytes("some text message"));

soc.Close();

------------------------------------------------------------------------------------------------

I have firewall enabled on the server box (where the listener is running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work.

Any ideas on how to detect where the problem is..?

Thanks much

Jay


Feb 9 '07 #7
Your code snippet says listener code but it looks more like client code.
Does an nslookup of myserver.domain.com return only one IP address?
Do you know which IP and/or interface AddressList[0] is binding too? Does
the server use similar code to setup the listener? Is it possible it's
binding to an IP that the remote machine does not have a route to? For
example, I have VMWare on my machine so there are 2 virtual adapters that
have private IPs that are not part of our local subnet. If my software
listened on one of those then remote machines would have no way of
connecting to me, but the same client running on my workstation would. Make
sure you are listening on the interface and IP you think you are listening
on.

jim
"Jay" <Ja*@microsoft.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>I have a socket listener and a test app.
The socket listener app: opens up the port 51296 and listens.
The test app - sends a message on port 51296.
If the listener and test app are on the same box, all is well - everything
works as expected.
But when I move my test app to a remote box: I get the following error:
"no connection could be made because the target machine actively refused
it"
--------------------------------------------------
This is the listener code:
IPHostEntry hostEntry = Dns.GetHostEntry(myserver.domain.com);

IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList[0], 51296);

Socket soc =

new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

soc.Connect(ipe);

soc.Send(Encoding.ASCII.GetBytes("some text message"));

soc.Close();

------------------------------------------------------------------------------------------------

I have firewall enabled on the server box (where the listener is running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work.

Any ideas on how to detect where the problem is..?

Thanks much

Jay


Feb 9 '07 #8
Jay
I tried changing the port number to 80 (which is a http port and it is
unblocked)
That did not work.

I did a netstat -a .
I saw that the app was listening on the port.

But when I tried "telnet <servername51296", it did not go through.

What else can I do?

"PokerMan" <no****@pokercat.co.ukwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...
Ignacio, at end of his post he says:

"I have firewall enabled on the server box (where the listener is
running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work."

My best advice since you cant turn it off is try changing the port number
and see if you have more luck. Sounds like the firewall is the reason
though. Do check if there is anything else blocking that port.

As a check try this, start your app listening.

then open a command prompt and type Netstat -a

This shows all connections. Ensure your app is listening on the port you
mentioned. If it is then try telnet to that port and see if the server
lets that through. I am sure you'll find it doesnt due to the firewall, if
it does then there is a problem with your client end software on how it
connects.

Definitely sounds like an administrative problem not a code one though.

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:eE**************@TK2MSFTNGP06.phx.gbl...
>Hi,

"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
|I cannot turn off the firewall. Its set by the corporate group policy.
| I have admin previlages to modify, but not turn it off completel

Well, then how do you expect that the remote client can connect to your
server if there is a firewall?

Either you remove your firewall or at least allow that port to pass
through.
--
Ignacio Machin
machin AT laceupsolutions com



Feb 9 '07 #9
Do a netstat -an and check the IP that the listener is bound to. Then try
to telnet to that IP and port instead of machine name and port. Also ping
that IP from the remote to make sure there is a route in place.
jim

"Jay" <Ja*@microsoft.comwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>I tried changing the port number to 80 (which is a http port and it is
unblocked)
That did not work.

I did a netstat -a .
I saw that the app was listening on the port.

But when I tried "telnet <servername51296", it did not go through.

What else can I do?

"PokerMan" <no****@pokercat.co.ukwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...
>Ignacio, at end of his post he says:

"I have firewall enabled on the server box (where the listener is
running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work."

My best advice since you cant turn it off is try changing the port number
and see if you have more luck. Sounds like the firewall is the reason
though. Do check if there is anything else blocking that port.

As a check try this, start your app listening.

then open a command prompt and type Netstat -a

This shows all connections. Ensure your app is listening on the port you
mentioned. If it is then try telnet to that port and see if the server
lets that through. I am sure you'll find it doesnt due to the firewall,
if it does then there is a problem with your client end software on how
it connects.

Definitely sounds like an administrative problem not a code one though.

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote
in message news:eE**************@TK2MSFTNGP06.phx.gbl...
>>Hi,

"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
|I cannot turn off the firewall. Its set by the corporate group policy.
| I have admin previlages to modify, but not turn it off completel

Well, then how do you expect that the remote client can connect to your
server if there is a firewall?

Either you remove your firewall or at least allow that port to pass
through.
--
Ignacio Machin
machin AT laceupsolutions com




Feb 9 '07 #10
Jay
I saw some thing interesting.
The server box has 2 "local area connections".
When I do an ipconfig on that box: I get 2 IP addresses.
Say for e.g: 1.1.1.1 and 2.2.2.2
When I run the listener it opens the port on 1.1.1.1 : 51296

But when I try to send the messages from my box: I only see 2.2.2.2.
I cannot ping 1.1.1.1 and therefore I cannot send messages to that box.

Any ideas why there are 2 IP addresses? Is that because of the firewall?

"Jim H" <ji**@nospam.nospamwrote in message
news:OE**************@TK2MSFTNGP02.phx.gbl...
Do a netstat -an and check the IP that the listener is bound to. Then try
to telnet to that IP and port instead of machine name and port. Also ping
that IP from the remote to make sure there is a route in place.
jim

"Jay" <Ja*@microsoft.comwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>>I tried changing the port number to 80 (which is a http port and it is
unblocked)
That did not work.

I did a netstat -a .
I saw that the app was listening on the port.

But when I tried "telnet <servername51296", it did not go through.

What else can I do?

"PokerMan" <no****@pokercat.co.ukwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...
>>Ignacio, at end of his post he says:

"I have firewall enabled on the server box (where the listener is
running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work."

My best advice since you cant turn it off is try changing the port
number and see if you have more luck. Sounds like the firewall is the
reason though. Do check if there is anything else blocking that port.

As a check try this, start your app listening.

then open a command prompt and type Netstat -a

This shows all connections. Ensure your app is listening on the port you
mentioned. If it is then try telnet to that port and see if the server
lets that through. I am sure you'll find it doesnt due to the firewall,
if it does then there is a problem with your client end software on how
it connects.

Definitely sounds like an administrative problem not a code one though.

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote
in message news:eE**************@TK2MSFTNGP06.phx.gbl...
Hi,

"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
|I cannot turn off the firewall. Its set by the corporate group policy.
| I have admin previlages to modify, but not turn it off completel

Well, then how do you expect that the remote client can connect to
your
server if there is a firewall?

Either you remove your firewall or at least allow that port to pass
through.
--
Ignacio Machin
machin AT laceupsolutions com




Feb 9 '07 #11
Jay
Found what the problem is.
I disabled one of the network connections, and now I am able to send
messages across.

"Jay" <Ja*@microsoft.comwrote in message
news:O8**************@TK2MSFTNGP05.phx.gbl...
>I saw some thing interesting.
The server box has 2 "local area connections".
When I do an ipconfig on that box: I get 2 IP addresses.
Say for e.g: 1.1.1.1 and 2.2.2.2
When I run the listener it opens the port on 1.1.1.1 : 51296

But when I try to send the messages from my box: I only see 2.2.2.2.
I cannot ping 1.1.1.1 and therefore I cannot send messages to that box.

Any ideas why there are 2 IP addresses? Is that because of the firewall?

"Jim H" <ji**@nospam.nospamwrote in message
news:OE**************@TK2MSFTNGP02.phx.gbl...
>Do a netstat -an and check the IP that the listener is bound to. Then
try to telnet to that IP and port instead of machine name and port. Also
ping that IP from the remote to make sure there is a route in place.
jim

"Jay" <Ja*@microsoft.comwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>>>I tried changing the port number to 80 (which is a http port and it is
unblocked)
That did not work.

I did a netstat -a .
I saw that the app was listening on the port.

But when I tried "telnet <servername51296", it did not go through.

What else can I do?

"PokerMan" <no****@pokercat.co.ukwrote in message
news:uN**************@TK2MSFTNGP03.phx.gbl...
Ignacio, at end of his post he says:

"I have firewall enabled on the server box (where the listener is
running).

I tried setting the firewall options to unblock the port 51296 for all
traffic.

That did not work."

My best advice since you cant turn it off is try changing the port
number and see if you have more luck. Sounds like the firewall is the
reason though. Do check if there is anything else blocking that port.

As a check try this, start your app listening.

then open a command prompt and type Netstat -a

This shows all connections. Ensure your app is listening on the port
you mentioned. If it is then try telnet to that port and see if the
server lets that through. I am sure you'll find it doesnt due to the
firewall, if it does then there is a problem with your client end
software on how it connects.

Definitely sounds like an administrative problem not a code one though.

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote
in message news:eE**************@TK2MSFTNGP06.phx.gbl...
Hi,
>
"Jay" <Ja*@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
|I cannot turn off the firewall. Its set by the corporate group
policy.
| I have admin previlages to modify, but not turn it off completel
>
Well, then how do you expect that the remote client can connect to
your
server if there is a firewall?
>
Either you remove your firewall or at least allow that port to pass
through.
>
>
--
Ignacio Machin
machin AT laceupsolutions com
>
>




Feb 9 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
2
by: Rene Sørensen | last post by:
We are 4 students working on a assignment, that our teacher gave use, normally we do this is C++, but the 4 of us, use C# more often that C++ so… We made a small games called reversi, now our job...
7
by: | last post by:
Hi all, I have a simple .aspx page running on net 2.0 that is trying to do a http post to a remote server. Here is the code Private Function ProcessRequests(ByVal strbody As String) As String...
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
2
by: John Nagle | last post by:
Here's a strange little bug. "socket.getaddrinfo" blows up if given a bad domain name containing ".." in Unicode. The same string in ASCII produces the correct "gaierror" exception. Actually,...
10
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1....
14
by: ahlongxp | last post by:
Hi, everyone, I'm implementing a simple client/server protocol. Now I've got a situation: client will send server command,header paires and optionally body. server checks headers and decides...
10
by: Hendrik van Rooyen | last post by:
While doing a netstring implementation I noticed that if you build a record up using socket's recv(1), then when you close the remote end down, the recv(1) hangs, despite having a short time out...
2
by: manasap | last post by:
Hi all! I've written a server and a client application using asynchronous sockets.The client sends data packets for every 7 seconds.The server receives the packets. This process proceeds...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.