Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub SendLED_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendLED.Click
- Dim message As String
- Dim container As String
- message = "The actual bytes string of a message to send"
- @@ container = &H1 & "Z" & &H30 & &H2 & "temp.nrg" & &H1C & "1Something" & &H4
- ' This did not appear to work neither
- 'container = Chr(&H1) & "Z" & Chr(&H30) & Chr(&H2) & Chr(&H1C) & "1Something" & Chr(&H4)
- @@ '<0x01>Z00<0x02>FILENAME<0x1C>1Test to display<0x04> <- the "official" spec to send
- '' DEL THIS CODE
- ' This constructor arbitrarily assigns the local port number.
- Dim udpClient As New UdpClient(9520)
- Try
- udpClient.Connect(txtIPaddress.Text, 9520)
- ' Sends a message to the host to which you have connected.
- Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(container)
- udpClient.Send(sendBytes, sendBytes.Length)
- ' UdpClient.Receive blocks until a message is received from a remote host.
- Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
- Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
- ' Which one of these two hosts responded?
- Console.WriteLine(("This is the message you received " + _
- returnData.ToString()))
- Console.WriteLine(("This message was sent from " + _
- RemoteIpEndPoint.Address.ToString() + _
- " on their port number " + _
- RemoteIpEndPoint.Port.ToString()))
- udpClient.Close()
- Catch eror As Exception
- Console.WriteLine(eror.ToString())
- End Try
- '' Del this code
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement