954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

WinSock in VB6 (SendData Problem)

I am developing an application in VB6 which will communicate using UDP Connection to a hardware which recieves and sends data using UDP Connection. My Hardware works fine. It has already been tested with an application written in VisualC using UDP connection only. In VisualC, I had working on UDP Connection without Winsock.
Hardware's Remote IP and Port is been set to my computer's IP and Port 4040.

My code for connection and sending data is as below :

[CODE]
If Winsock1.State = sckClosed Then
Winsock1.Protocol = sckUDPProtocol
Winsock1.LocalPort = 4040
Winsock1.RemoteHost = "192.168.1.80" 'Hardware IP
Winsock1.RemotePort = 4040 'Hardware's Port
Winsock1.connect
Winsock1.SendData "Hello"
Else
Winsock1.Close
End If
[\CODE]

I debugged this code and also the hardware and i found that
1. A Packet is sent to the hardware after WinSock1.connect command is executed.
2. But no Packet is been send after SendData Command as it requires Winsock1 in Connected State.

I want to know if i could senddata using winsock without my connection being accepted by the remote machine(hardware).
I am even able to recieve messages from Hardware on the DataArrival Function.

deepmadan
Newbie Poster
8 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Put a DoEvents after the line "Winsock1.connect". Should work fine after that.

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: