|
-
Oct 14th, 2004, 04:36 AM
#1
Thread Starter
Addicted Member
best way to send data over network?
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
-
Oct 21st, 2004, 03:11 AM
#2
Fanatic Member
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
-
Oct 21st, 2004, 04:23 AM
#3
Thread Starter
Addicted Member
thanks, but i need more lower level help!
how to send / recieve a few bytes...
winsocket i guess..
-
Oct 26th, 2004, 05:54 AM
#4
-
Nov 8th, 2004, 08:01 PM
#5
New Member
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
-
Nov 27th, 2004, 09:07 AM
#6
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
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
-
Nov 29th, 2004, 11:55 AM
#7
New Member
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.
-
Nov 29th, 2004, 04:00 PM
#8
Thread Starter
Addicted Member
Hi thanks both for your comments.
A simple UDP will do me , I think.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|