473,399 Members | 3,888 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,399 software developers and data experts.

Socket problem (Connection refused)

Hi I'm created a socket listening on port 1234 (it is shown that this post
is in listening mode if I use NETSTAT). Now Iam trying to connect to this
port:

IPHostEntry entry = Dns.Resolve("localhost");
serverConn = new Socket(entry.AddressList[0].AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(entry.AddressList[0], 1234);
serverConn.Connect(endpoint);

But I get a SocketException that the remotecomputer has denied the
connection request. What could be the cause of this? Both apps running local
and I have no firewall (Win2K).

I tried Accept() in blocking and nonblocking mode on the server but neither
worked.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 22 '05 #1
5 12608
both server and client must have same port. i'm not familiar NETSTAST.
"the connection refused mean the other side must have same port as the
other side..
i'm only working on system.net. similar to mirc.
regards,

cody wrote:
Hi I'm created a socket listening on port 1234 (it is shown that this post
is in listening mode if I use NETSTAT). Now Iam trying to connect to this
port:

IPHostEntry entry = Dns.Resolve("localhost");
serverConn = new Socket(entry.AddressList[0].AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(entry.AddressList[0], 1234);
serverConn.Connect(endpoint);

But I get a SocketException that the remotecomputer has denied the
connection request. What could be the cause of this? Both apps running local
and I have no firewall (Win2K).

I tried Accept() in blocking and nonblocking mode on the server but neither
worked.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk


Nov 22 '05 #2
Hi cody,
what happens if with listening started you call from command prompt:

telnet localhost 1234?

Also, how you create the listener?

Sunny
In article <#T**************@TK2MSFTNGP11.phx.gbl>,
no****************@gmx.net says...
Hi I'm created a socket listening on port 1234 (it is shown that this post
is in listening mode if I use NETSTAT). Now Iam trying to connect to this
port:

IPHostEntry entry = Dns.Resolve("localhost");
serverConn = new Socket(entry.AddressList[0].AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(entry.AddressList[0], 1234);
serverConn.Connect(endpoint);

But I get a SocketException that the remotecomputer has denied the
connection request. What could be the cause of this? Both apps running local
and I have no firewall (Win2K).

I tried Accept() in blocking and nonblocking mode on the server but neither
worked.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

Nov 22 '05 #3
> what happens if with listening started you call from command prompt:

telnet localhost 1234?
Good idea I'll try it tomorrow in my company.
Also, how you create the listener?
I do not have the src here but I think I did it this way:

IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
socket.Bind(new IPEndPoint(ipAddress, 1234));
socket.Listen(10);
Socket s = socket.Accept(); // exception thrown here
In article <#T**************@TK2MSFTNGP11.phx.gbl>,
no****************@gmx.net says...
Hi I'm created a socket listening on port 1234 (it is shown that this post is in listening mode if I use NETSTAT). Now Iam trying to connect to this port:

IPHostEntry entry = Dns.Resolve("localhost");
serverConn = new Socket(entry.AddressList[0].AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(entry.AddressList[0], 1234);
serverConn.Connect(endpoint);

But I get a SocketException that the remotecomputer has denied the
connection request. What could be the cause of this? Both apps running local and I have no firewall (Win2K).

I tried Accept() in blocking and nonblocking mode on the server but neither worked.

Nov 22 '05 #4
Hi,

try with:

socket.Bind(new IPEndPoint(IPAddress.Any, 1234);

this will bind the socket to all adapters.

If it works, you have to investigate why and if DNS resolve returns
different IPAddresses on the client and on the server.

Sunny

In article <u2**************@TK2MSFTNGP12.phx.gbl>,
pl*************************@gmx.de says...
what happens if with listening started you call from command prompt:

telnet localhost 1234?


Good idea I'll try it tomorrow in my company.
Also, how you create the listener?


I do not have the src here but I think I did it this way:

IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
socket.Bind(new IPEndPoint(ipAddress, 1234));
socket.Listen(10);
Socket s = socket.Accept(); // exception thrown here
In article <#T**************@TK2MSFTNGP11.phx.gbl>,
no****************@gmx.net says...
Hi I'm created a socket listening on port 1234 (it is shown that this post is in listening mode if I use NETSTAT). Now Iam trying to connect to this port:

IPHostEntry entry = Dns.Resolve("localhost");
serverConn = new Socket(entry.AddressList[0].AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(entry.AddressList[0], 1234);
serverConn.Connect(endpoint);

But I get a SocketException that the remotecomputer has denied the
connection request. What could be the cause of this? Both apps running local and I have no firewall (Win2K).

I tried Accept() in blocking and nonblocking mode on the server but neither worked.


Nov 22 '05 #5
> Hi,

try with:

socket.Bind(new IPEndPoint(IPAddress.Any, 1234);

this will bind the socket to all adapters.

If it works, you have to investigate why and if DNS resolve returns
different IPAddresses on the client and on the server.

You are right, that was the problem!

Thank you!

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 22 '05 #6

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

Similar topics

0
by: anuradha.k.r | last post by:
hi, i have written a simple socket program in python to connect to a windows machine.On the server side i am running a windows socket program which works perfectly fine,my server program waites at...
2
by: Maxim Olivier-Adlhoch | last post by:
hello , this is my first post on this list. I've been told its very helpfull, I hope someone can help me with my problem. I've been building a specialized client server application using...
4
by: Alex Hunsley | last post by:
I am using the smtp module to send emails via a local SMTP server on our network. I am failing with "connection refused" error, even though we definitely have an smtp server running on port 25! ...
8
by: Josh Close | last post by:
I'm using the smtplib module and I keep getting this error: (111, 'Connection refused') What could be causing this? I've tried it from a different computer and it seems to work, but not from this...
5
by: cody | last post by:
Hi I'm created a socket listening on port 1234 (it is shown that this post is in listening mode if I use NETSTAT). Now Iam trying to connect to this port: IPHostEntry entry =...
1
by: niceyama | last post by:
Dear c.l.p, I have recently been doing the tutorial of Python and everything is well, i'm upto the pass section. Anyway, when I try to launch idle now I get the error message: Socket Error:...
2
by: Vania | last post by:
Hi, I'm not sure this is the proper forum but I try nevertheless. The problem I'am facing is that the socket library always fail to connect to an URL. The net effect is that I can not use...
1
by: Sergey Kozyrev | last post by:
Hi all, I'm trying to test my rulecore program with Event Generator but when I generate new event, I got error message: "Socket error: Connection refused, error code 10061". What can it be? It's...
2
by: cirfu | last post by:
The first time i start the shell it always works. But often after closing it and restarting it I get: Two windows pops up and the shell, after clicking the windows the shell just closes by...
4
by: phpuser123 | last post by:
I just tried to create a small socket application with reference to tutorials on the web.. Hers's the script for the socket application package sockets_1; import java.net.*; import java.io.*;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.