Advertisement
Guest User

SuperRoach

a guest
Dec 7th, 2008
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.87 KB | None | 0 0
  1.     Private Sub SendLED_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendLED.Click
  2.         Dim message As String
  3.         Dim container As String
  4.         message = "The actual bytes string of a message to send"
  5. @@        container = &H1 & "Z" & &H30 & &H2 & "temp.nrg" & &H1C & "1Something" & &H4
  6.         '    This did not appear to work neither
  7.         'container = Chr(&H1) & "Z" & Chr(&H30) & Chr(&H2) & Chr(&H1C) & "1Something" & Chr(&H4)
  8. @@        '<0x01>Z00<0x02>FILENAME<0x1C>1Test to display<0x04>   <- the "official" spec to send
  9.  
  10.  
  11.         '' DEL THIS CODE
  12.         ' This constructor arbitrarily assigns the local port number.
  13.         Dim udpClient As New UdpClient(9520)
  14.         Try
  15.             udpClient.Connect(txtIPaddress.Text, 9520)
  16.  
  17.             ' Sends a message to the host to which you have connected.
  18.             Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(container)
  19.  
  20.             udpClient.Send(sendBytes, sendBytes.Length)
  21.  
  22.  
  23.             ' UdpClient.Receive blocks until a message is received from a remote host.
  24.             Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
  25.             Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
  26.  
  27.             ' Which one of these two hosts responded?
  28.             Console.WriteLine(("This is the message you received " + _
  29.                                           returnData.ToString()))
  30.             Console.WriteLine(("This message was sent from " + _
  31.                                          RemoteIpEndPoint.Address.ToString() + _
  32.                                          " on their port number " + _
  33.                                          RemoteIpEndPoint.Port.ToString()))
  34.             udpClient.Close()
  35.  
  36.         Catch eror As Exception
  37.             Console.WriteLine(eror.ToString())
  38.         End Try
  39.         '' Del this code
  40.     End Sub
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement