473,396 Members | 1,900 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,396 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 4055
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.