OK en lille opskrift altså :
Punkt 1 - Find ud af hvordan man laver og bruger et com object, så en lille tutorial :
http://stardeveloper.com:8080/com_vb_basic_1.aspDen forklare hvordan man laver et COM object og det er på ingen måde langhåret.
Punkt 2 - Her er pasted noget fra MSDN om lidt UDP :
---------------------------------------------------------------------------------------------------
UDP Basics
Creating a UDP application is even simpler than creating a TCP application because the UDP protocol doesn\'t require an explicit connection. In the TCP application above, one Winsock control must explicitly be set to \"listen,\" while the other must initiate a connection with the Connect method.
In contrast, the UDP protocol doesn\'t require an explicit connection. To send data between two controls, three steps must be completed (on both sides of the connection):
Set the RemoteHost property to the name of the other computer.
Set the RemotePort property to the LocalPort property of the second control.
Invoke the Bind method specifying the LocalPort to be used. (This method is discussed in greater detail below.)
Because both computers can be considered \"equal\" in the relationship, it could be called a peer-to-peer application. To demonstrate this, the code below creates a \"chat\" application that allows two people to \"talk\" in real time to each other:
To create a UDP Peer
Create a new Standard EXE project.
Change the name of the default form to frmPeerA.
Change the caption of the form to \"Peer A.\"
Draw a Winsock control on the form and name it udpPeerA.
On the Properties page, click Protocol and change the protocol to UDPProtocol.
Add two TextBox controls to the form. Name the first txtSend, and the second txtOutput.
Add the code below to the form.
Private Sub Form_Load()
\' The control\'s name is udpPeerA
With udpPeerA
\' IMPORTANT: be sure to change the RemoteHost
\' value to the name of your computer.
.RemoteHost= \"PeerB\"
.RemotePort = 1001 \' Port to connect to.
.Bind 1002 \' Bind to the local port.
End With
frmPeerB.Show \' Show the second form.
End Sub
Private Sub txtSend_Change()
\' Send text as soon as it\'s typed.
udpPeerA.SendData txtSend.Text
End Sub
Private Sub udpPeerA_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
udpPeerA.GetData strData
txtOutput.Text = strData
End Sub
To create a second UDP Peer
Add a standard form to the project.
Change the name of the form to frmPeerB.
Change the caption of the form to \"Peer B.\"
Draw a Winsock control on the form and name it udpPeerB.
On the Properties page, click Protocol and change the protocol to UDPProtocol.
Add two TextBox controls to the form. Name the TextBox txtSend, and the second txtOutput.
Add the code below to the form.
Private Sub Form_Load()
\' The control\'s name is udpPeerB.
With udpPeerB
\' IMPORTANT: be sure to change the RemoteHost
\' value to the name of your computer.
.RemoteHost= \"PeerA\"
.RemotePort = 1002 \' Port to connect to.
.Bind 1001 \' Bind to the local port.
End With
End Sub
Private Sub txtSend_Change()
\' Send text as soon as it\'s typed.
udpPeerB.SendData txtSend.Text
End Sub
Private Sub udpPeerB_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
udpPeerB.GetData strData
txtOutput.Text = strData
End Sub
To try the example, press F5 to run the project, and type into the txtSend TextBox on either form. The text you type will appear in the txtOutput TextBox on the other form.
About the Bind Method
As shown in the code above, you must invoke the Bind method when creating a UDP application. The Bind method \"reserves\" a local port for use by the control. For example, when you bind the control to port number 1001, no other application can use that port to \"listen\" on. This may come in useful if you wish to prevent another application from using that port.
The Bind method also features an optional second argument. If there is more than one network adapter present on the machine, the LocalIP argument allows you to specify which adapter to use. If you omit the argument, the control uses the first network adapter listed in the Network control panel dialog box of the computer\'s Control Panel Settings.
When using the UDP protocol, you can freely switch the RemoteHost and RemotePort properties while remaining bound to the same LocalPort. However, with the TCP protocol, you must close the connection before changing the RemoteHost and RemotePort properties.
---------------------------------------------------------------------------------------------------
Skriv hele lortet ud, og læs det igennem. Prøv evt. at søge på UDP og winsock på msdn.microsoft.com for at få mere info. lav nogle forsøg med det, og tag så fat på stats programmet.
Du kan i min source kode se i playerextractor, rulesextractor, infoextractor hvordan de forskellige udp pakker er sat sammen. Det skulle være rimelig lige til, så go fornøjelse.
Hvis det lykkes for dig, ville jeg da meget gerne se et eksemplar, hvis du vil lave det frit tilgængeligt selvfølgelig.
Hvis der er spørgsmål, eller andet står jeg selvfølgelig også til rådighed....Go arbejdslyst.
Kasper