using VB6
i want to send small amount of data (<50 bytes) between 2 computers on a network every 1 minute.
error checking will be in the data, so no security, etc required.
What is the best way ?
Any code examples ?
thanks
Printable View
using VB6
i want to send small amount of data (<50 bytes) between 2 computers on a network every 1 minute.
error checking will be in the data, so no security, etc required.
What is the best way ?
Any code examples ?
thanks
Use a propertybag object and send the propertybag.content string. Because the string is a native type, you will minimise your marshalling and the data size is usually pretty good.
Another option would be zip an xml file. XML is usually pretty large, but compressed, you can get some really good sizes. When you uncompress it, you will have all the nice XML functionality like format checking using XSD, format transformations using XSLT etc.
Heres a good article on when to use xml: The XML Litmus Test
thanks, but i need more lower level help!
how to send / recieve a few bytes...
winsocket i guess..
Or use a DCOM Singleton:
http://www.vbforums.com/showthread.p...hreadid=310205
The easiest way is to use UDP in the Winsock control. Remember it is connectionless and the message is not guaranteed to arrive at the destination. So you have to plan for that!
example: Simplistic but not too far off!
VB Code:
'Sender: udpSocket.RemoteHost = cmbRemoteHost.Text ' IP or DNS udpSocket.RemotePort = Val(txtRemotePort.Text) ' like 2001 udpSocket.SendData msg$ 'Reciever: DataArrival event fires Private Sub udpSocket_DataArrival(ByVal bytesTotal As Long) Dim strData As String Dim strTag As String On Error Resume Next Err = 0 Beep udpSocket.GetData strData If Err Then txtStatus.Text = Error Exit Sub End If txtStatus.Text = strData End
thats only one of the 2 protocalls winsock has, it has a connection one as well :) which is MORE likly to get data there :)Quote:
Originally posted by altwies
The easiest way is to use UDP in the Winsock control. Remember it is connectionless and the message is not guaranteed to arrive at the destination. So you have to plan for that!
example: Simplistic but not too far off!
VB Code:
'Sender: udpSocket.RemoteHost = cmbRemoteHost.Text ' IP or DNS udpSocket.RemotePort = Val(txtRemotePort.Text) ' like 2001 udpSocket.SendData msg$ 'Reciever: DataArrival event fires Private Sub udpSocket_DataArrival(ByVal bytesTotal As Long) Dim strData As String Dim strTag As String On Error Resume Next Err = 0 Beep udpSocket.GetData strData If Err Then txtStatus.Text = Error Exit Sub End If txtStatus.Text = strData End
www.winsockvb.com
True! There are connected sockets but UDP will be the lease complicated of the two and consume the least network resources, especially because a connection with all of its handshaking does not need to be created and destroyed each time. On the other hand, if network resources were sufficient and you wanted to leave the connection open for indeterminate amounts of time, a connected socket would due as well. The code to handle this is not too much more complicated but you would have to consider handling or disabling socket timeouts and other similar things.
Hi thanks both for your comments.
A simple UDP will do me , I think.