473,287 Members | 1,800 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,287 software developers and data experts.

Can't hear vb6 winsock connect request in C# listener

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.Strea m, ProtocolType.Tcp );
listener.Bind(localEndPoint);
listener.Listen(10);
Console.WriteLine("Waiting");

listener.Accept();
Console.WriteLine("Connection request - press enter to continue");
Console.ReadLine();
}
}
}

Nov 22 '05 #1
3 4045
Hi Bill,

Thanks for your post. I am building a solution to check this issue and will
update you with my findings.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #2
Hi Bill,

I reproduce the problem on my side, and now I'd like to share the following
information with you:

The reason why C# socket server cannot hear the connection requst from VB6
client is that it listens at the ip address other than 127.0.0.1. If I
changed to the following line in your code, and now it works as expected:
IPHostEntry ipHostInfo = Dns.Resolve("localhost");

Please check it on your side and feel free to let me know if you have any
problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #3
Very interesting. When I switch to localhost, I can indeed hear the local
requests, but then I cannot hear outside requests. I guess the only
behavior I've every observed (Winsock, Internet Explorer, etc.) is that
localhost and machine name can be used interchangably. It should be no
problem for me to listen to the port on both addresses though.

Thank you very much for your assistance!

-Bill.
Nov 22 '05 #4

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

Similar topics

2
by: Dan | last post by:
I'm writing a simplistic telnet client in VB6 and I've run into a small snag. The program has a textbox to write in the string to be sent using ..SendData and has another textbox that displays...
0
by: Ted | last post by:
I'm writing an app that returns a client's IP when they click a link to my IP in AIM. I have the app listening on port 80, and then after they click the link I press a command button that puts a...
4
by: Ellen K. | last post by:
Hi all, Being that so far I didn't get an answer to my below problem on the Oracle newsgroup, I figured it couldn't hurt to try here. While at my current job I've been working with mostly SQL...
3
by: Bill | last post by:
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...
1
by: Dom | last post by:
I'm new to c++. Just started learning it 24 hours ago. Am running into a compile problem. Please, no one waste the effort telling me to google it. I've been researching it for quite a while with no...
12
by: zhimin | last post by:
With C#, I had created two threads in one program. One is a TCP listener, and the other is TcpClient. After the Listener thread started, the client thread started try to connect to the listener,...
1
by: Vincent | last post by:
I do not have a strong grasp of the winsock library, but have started fiddling around with it a bit. My first impression is that using winsock in Access is a bit unwieldy. I was making a...
4
by: penkomitev | last post by:
Hello! First, excuse me if I have any mistakes because Bulgarian is my native language and English is a foreign one. So the problem is: I have a chat program with to parts: server and client ones....
3
by: RFD | last post by:
I've been slaving at this problem for over a week, and would appreciate some help from you kind folks. Basic Problem: I have made a server program and a client program. When I try to use the...
2
by: =?Utf-8?B?YmJn?= | last post by:
Hi all, I am testing how well my server application is connecting to multiple clients and give and take some information. All actions(connect, accept, send, receive) are performed by async...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.