Click here to Skip to main content
15,610,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

Please bare with me with this as I am somewhat new to using the Winsock control with VB6.

The situation is this,

The requirement is that I use UDP and not TCP

I have an application running on a computer which we will call ComputerA that needs to listen for data coming from another computer which we will call ComputerB. The application on ComputerA will listen for this data and once received, then it needs to send data to ComputerB.

Since this application needs to act as a client for receiving data and a server for sending data, I will be using two Winsock controls, one called ListenerClient (the receiver) and another called SenderServer (the sender).

I have on a Form the following:

1. A button called Receive with the following code behind it:

ListenerClient.Protocol = sckUDPProtocol
ListenerClient.Bind 2727

The code for the DataArrival event is as follows:

Private Sub ListenerClient_DataArrival(ByVal bytesTotal As Long)

Dim sData As String
ListenerClient.GetData sData, vbString
MsgBox sData

End Sub

2. A button called Send with the following code behind it:

SenderServer.Protocol = sckUDPProtocol
SenderServer.RemoteHost = "XXX.XXX.X.XXX"
SenderServer.RemotePort = 2727
SenderServer.SendData "Message Sent From The Desktop Computer!"

Where XXX.XXX.X.XXX is the IP Address for the Laptop that I am using to send data to
Please note that I was concerned about specifying the actual IP address but can supply it is necessary.

As a test, I have been running the same application on my Desktop computer and my Laptop computer.

I am able to send data from the Desktop to the Laptop but not from the Laptop to the Desktop.

Am I doing everything correctly here, or is it just an IP address issue?

I hope I explained everything correctly

Thank you


What I have tried:

I have searched the internet but for items of interest but saw that it was written in c#
Updated 13-Dec-21 5:58am
Gerry Schmitz 10-Dec-21 13:26pm    
A server "listens"; then responds to a request. The client "asks", then waits for a response. In your scenario, the server "sends", then has to receive. That's not how a client-server scenario works.
gary hagerty 10-Dec-21 13:38pm    

Thank you very much for your response.

I appologies if I got the terminolgy wrong.

The question that I have is I can send data using the Winsock control in VB6 using UDP from my desktop to the laptop, but cannot send data from my laptop to my desktop.

Why would that be?

Thank you
Greg Utas 11-Dec-21 7:27am    
If you've got the IP addresses and other details correct, see if the desktop has a firewall that is blocking incoming packets.
Richard Deeming 13-Dec-21 4:14am    
"Somewhat new" and "VB6" don't belong in the same sentence!

VB6 has been dead for 20 years. Unless you're stuck maintaining an ancient already-existing application, you shouldn't be going anywhere near VB6.
gary hagerty 13-Dec-21 10:04am    
Thank you for your comments

Yes, I understand what you are saying, but I am kind off stuck with having to do this in VB6, since the DLL's that I used to interface to our embedded controls were done in VB6 as well.

I beleieve that I managed to solve this issue.

Thank you for your time

1 solution

but I am kind off stuck with having to do this in VB6, since the DLL's that I used to interface to our embedded controls were done in VB6 as well.
No - you're not :-)
See Solution 2 to this question How to use vb6 DLL function in C# .NET using 4.6.1 framework[^]
There is also further information here[^]
Share this answer
gary hagerty 13-Dec-21 12:51pm    
Hello Sir,

I understand that it is possible to have a VB.NET application use DLL's written in VB6, but one of the things that we found is that doing so would slow down the application.

Thank you for your comments and time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900