Hi,I have a problem connecting to a server using Sockets. The owner/administrator of the server sais that there should be no problems doing so. There should be no restrictions for me to connect to the port I want to connect to. But the server refuses my connection. Anyone got any ideas of what's wrong? Is it likely that there actuctually are some restrictions fom me or could something be wrong on my side?I do the following and gets an exception (printed below the source code):
IPHostEntry IPHost = Dns.Resolve("xxxxxx");
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
EndPoint ep = new IPEndPoint(addr[0],5000);
Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
try {
sock.Connect(ep);
} catch(ArgumentNullException ae) {
Console.WriteLine("ArgumentNullException : {0}", ae.ToString());
} catch(SocketException se) {
Console.WriteLine("SocketException : {0}", se.ToString());
Console.WriteLine("help link : {0}", se.HelpLink);
Console.WriteLine("source : {0}", se.Source);
Console.WriteLine("message : {0}", se.Message);
Console.WriteLine("errorCode : {0}", se.ErrorCode);
Console.WriteLine("TargetSite : {0}", se.TargetSite);
Console.WriteLine("StackTrace : {0}", se.StackTrace);
Console.WriteLine("NativeErrorCode : {0}", se.NativeErrorCode);
} catch(Exception e) {
Console.WriteLine("Unexpected exception : {0}", e.ToString());
}if(sock.Connected){
Console.WriteLine("socket OK");
}else{Console.WriteLine("socket NOT OK");}
SocketException : System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at TestApp1.processor.startProcessor() in c:\openfolder\visualstudio projects\testapp1\testapp1\processor.cs:line 137
help link :
source : System
message : No connection could be made because the target machine actively refused it
errorCode : 10061
TargetSite : Void Connect(System.Net.EndPoint)
StackTrace : at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
NativeErrorCode : 10061
socket NOT OK