B
Bill
When vb6 Winsock.RemoteHost is set to "127.0.0.1", c# socket listener cannot hear connect request (my old vb6 winsock listener could hear it...).
Why doesn't this work, and is there a work around I can make on the C# side to hear the connect request?
-Bill
(don't reply by e-mail, the address is a fake)
______________________________
Steps to reproduce:
Start the C# Listener
Start the VB6 Listener
Run the VB6 Client from IDE
Notice at 1st breakpoint C# didn't see connect request (HERE IS THE PROBLEM)
Notice at 2nd breakpoint VB6 listener did see connect request (just to prove it works with Winsock)
Notice that if we use the computer name, C# can see the request (just to prove C# listener is working)
______________________________
VB6 Client: Create a new vb6 project and add the MS Winsock control to toolbox. Drop two on the blank form. Add this code:
Private Sub Form_Load()
Winsock1.RemoteHost = "127.0.0.1"
Winsock1.RemotePort = 1000
Winsock1.Connect
Stop
Winsock2.RemoteHost = "127.0.0.1"
Winsock2.RemotePort = 1001
Winsock2.Connect
Stop
Winsock1.Close
Winsock1.RemoteHost = Winsock1.LocalHostName
Winsock1.Connect
End Sub
______________________________
VB6 Listener: Create a new vb6 project and add the MS Winsock control to the toolbox. Drop one on the blank form. Add this code:
Private Sub Form_Load()
Winsock1.LocalPort = 1001
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
MsgBox "Connect Request"
End Sub
______________________________
C# Listener: Create a new C# console app. Add this code:
using System;
using System.Net;
using System.Net.Sockets;
namespace ConsoleApplication23 {
class Class1 {
[STAThread]
static void Main(string[] args) {
IPEndPoint localEndPoint=null;
// NOTE: DNS lookups are nice and all but quite time consuming.
string sHostName = Dns.GetHostName();
IPHostEntry ipHostInfo = Dns.Resolve(sHostName);
IPAddress ipAddress = ipHostInfo.AddressList[0];
localEndPoint = new IPEndPoint(ipAddress, 1000);
Socket listener = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp );
listener.Bind(localEndPoint);
listener.Listen(10);
Console.WriteLine("Waiting");
listener.Accept();
Console.WriteLine("Connection request - press enter to continue");
Console.ReadLine();
}
}
}
Why doesn't this work, and is there a work around I can make on the C# side to hear the connect request?
-Bill
(don't reply by e-mail, the address is a fake)
______________________________
Steps to reproduce:
Start the C# Listener
Start the VB6 Listener
Run the VB6 Client from IDE
Notice at 1st breakpoint C# didn't see connect request (HERE IS THE PROBLEM)
Notice at 2nd breakpoint VB6 listener did see connect request (just to prove it works with Winsock)
Notice that if we use the computer name, C# can see the request (just to prove C# listener is working)
______________________________
VB6 Client: Create a new vb6 project and add the MS Winsock control to toolbox. Drop two on the blank form. Add this code:
Private Sub Form_Load()
Winsock1.RemoteHost = "127.0.0.1"
Winsock1.RemotePort = 1000
Winsock1.Connect
Stop
Winsock2.RemoteHost = "127.0.0.1"
Winsock2.RemotePort = 1001
Winsock2.Connect
Stop
Winsock1.Close
Winsock1.RemoteHost = Winsock1.LocalHostName
Winsock1.Connect
End Sub
______________________________
VB6 Listener: Create a new vb6 project and add the MS Winsock control to the toolbox. Drop one on the blank form. Add this code:
Private Sub Form_Load()
Winsock1.LocalPort = 1001
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
MsgBox "Connect Request"
End Sub
______________________________
C# Listener: Create a new C# console app. Add this code:
using System;
using System.Net;
using System.Net.Sockets;
namespace ConsoleApplication23 {
class Class1 {
[STAThread]
static void Main(string[] args) {
IPEndPoint localEndPoint=null;
// NOTE: DNS lookups are nice and all but quite time consuming.
string sHostName = Dns.GetHostName();
IPHostEntry ipHostInfo = Dns.Resolve(sHostName);
IPAddress ipAddress = ipHostInfo.AddressList[0];
localEndPoint = new IPEndPoint(ipAddress, 1000);
Socket listener = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp );
listener.Bind(localEndPoint);
listener.Listen(10);
Console.WriteLine("Waiting");
listener.Accept();
Console.WriteLine("Connection request - press enter to continue");
Console.ReadLine();
}
}
}