Click to See Complete Forum and Search --> : best way to send data over network?
donW
Oct 14th, 2004, 05:36 AM
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
shunt
Oct 21st, 2004, 04:11 AM
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 (http://msdn.microsoft.com/xml/buildingxml/xmlcolumns/default.aspx?pull=/library/en-us/dnexxml/html/xml10202004.asp)
donW
Oct 21st, 2004, 05:23 AM
thanks, but i need more lower level help!
how to send / recieve a few bytes...
winsocket i guess..
Dave Sell
Oct 26th, 2004, 06:54 AM
Or use a DCOM Singleton:
http://www.vbforums.com/showthread.php?s=&threadid=310205
altwies
Nov 8th, 2004, 08:01 PM
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!
'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
Pino
Nov 27th, 2004, 09:07 AM
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!
'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 :)
www.winsockvb.com
altwies
Nov 29th, 2004, 11:55 AM
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.
donW
Nov 29th, 2004, 04:00 PM
Hi thanks both for your comments.
A simple UDP will do me , I think.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.