Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

WinSock in VB6 (SendData Problem)

Status
Not open for further replies.

deepmadan

Newbie level 5
Joined
Jul 12, 2010
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Delhi
Activity points
1,340
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.
 

Run the listener program in your remote PC


Code Visual Basic - [expand]
1
2
Winsock1.LocalPort = "4040"
Winsock1.Listen

 

Run the listener program in your remote PC


Code Visual Basic - [expand]
1
2
Winsock1.LocalPort = "4040"
Winsock1.Listen


the remote machine is not a PC but a microcontroller hardware. I cant modify that hardware as it is working fine and i need an application to communicate with it. I can only put debug points in that hardware to see if any packet is recieved or not. This hardware was working fine with a VisualC application.

Both Hardware and VisualC were using Socket and WSAStartup and all its related functions for communicating and were working fine.

I was unable to use all the functions in VB so i tried using the winsock control.

Is there any way i could use winsock control or any other control to communicate with the hardware. Microcontroller Hardware will recieve all the data that comes on port 4040 on its IP.
 

You may check with another pc to check whether your sender program is working properly.

Or else you may try "telnet" like program to check your hardware
 

My hardware works fine with an application developed in VisualC. But both of them were developed without winsock. They used WSAStartup, recv and send functions for connection and sending, recieving data.

anyway i will try and check this code by connecting with another pc.

Is it possible to use WSAStartup, Send, Recv functions in VB too..???? If yes, please guide me....
 

another option is, you may try to create dll file if possible and then import to VB
 

another option is, you may try to create dll file if possible and then import to VB

I just found out that...
after WinSock1.Connect a Packet is recieved at the hardware (microcontroller) with length of 40 bytes. Packet contains my local ip and remote ip 192.168.1.80

But after WinSock1.SendData a Packet do gets recieved at the hardware but its length is 0.

I am debugging the hardware at the first layer only.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top