G
Guest
I have a remote server that I need to connect to and this is the parameter
that will be passed to my program in C#...
"\\server_name\share$"
I tried sockets. The foll is the code that I give in...
remoteHost = "xxx.xx.com"; //actual name is entered in here
remotePort = 0; //since I do not have a port number
IPHostEntry hostEntry = Dns.Resolve(remoteHost);
foreach(IPAddress address in hostEntry.AddressList)
{
IPEndPoint ipep = new IPEndPoint(address, remotePort);
clientSocket = new Socket(ipep.AddressFamily, SocketType.Stream,
ProtocolType.Tcp);
Console.WriteLine("Address {0}", Convert.ToString(address));
try
{
clientSocket.Connect(ipep);
}
catch(SocketException se)
{
Console.WriteLine("Code: {0}, Msg:
{1}",se.NativeErrorCode,se.Message );
}
}
Result--
It is able to resolve the netbios name to an ip address but since I do not
have the remote port number,
the error code is "10061" and the
error message is - "No connection could be made because the target machine
actively refused it."
Is there a way to get around giving the port number and simply connect using
the share name?
Thanks in advance
Jan
that will be passed to my program in C#...
"\\server_name\share$"
I tried sockets. The foll is the code that I give in...
remoteHost = "xxx.xx.com"; //actual name is entered in here
remotePort = 0; //since I do not have a port number
IPHostEntry hostEntry = Dns.Resolve(remoteHost);
foreach(IPAddress address in hostEntry.AddressList)
{
IPEndPoint ipep = new IPEndPoint(address, remotePort);
clientSocket = new Socket(ipep.AddressFamily, SocketType.Stream,
ProtocolType.Tcp);
Console.WriteLine("Address {0}", Convert.ToString(address));
try
{
clientSocket.Connect(ipep);
}
catch(SocketException se)
{
Console.WriteLine("Code: {0}, Msg:
{1}",se.NativeErrorCode,se.Message );
}
}
Result--
It is able to resolve the netbios name to an ip address but since I do not
have the remote port number,
the error code is "10061" and the
error message is - "No connection could be made because the target machine
actively refused it."
Is there a way to get around giving the port number and simply connect using
the share name?
Thanks in advance
Jan