Oppure

Loading
11/07/13 13:22
raffa505
Salve stò sperimentando un programma per inviare ricevere pacchetti HEX

sono riuscito a ricevere dei pacchetti ma non riesco a inviare in modo corretto...

sono riuscito a ricevere: 09 00 (2 byte)
devo rispondere con: 0a 00 (2 byte)

Dim receiveBytes As [Byte]() = UdpClient.Receive(RemoteIpEndPoint)
'Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
Dim returnData As String = gethex(receiveBytes)

buffer = "This is the message you received " & returnData.ToString() & vbCrLf _
   & "This message was sent from " & RemoteIpEndPoint.Address.ToString() & " on their port number " _
   & RemoteIpEndPoint.Port.ToString() & vbCrLf

Select Case returnData
   Case "90"
      Dim sb(1) As [Byte]
       sb(0) = 11
       sb(1) = 0

      Fsender.sendpacket(sb, 62228)
      buffer &= "Replyed " & gethex(sb) & vbCrLf
End Select

buffer &= vbCrLf


funzione gethex
Public Function gethex(bytes As [Byte]()) As String
   Dim s As String = ""
   For Each b As [Byte] In bytes
      s &= CStr(b) & " "
   Next
   Return s
End Function


funzione sendpacket
Public Sub sendpacket(sendBytes As [Byte](), door As Integer)
   Dim UdpClient As New UdpClient(door)
   UdpClient.Send(sendBytes, sendBytes.Length, "127.0.0.1", door)
End Sub


grazie
Ultima modifica effettuata da raffa505 11/07/13 17:18
aaa
13/07/13 9:07
raffa505
up aiuto!
aaa
16/07/13 15:50
LittleHacker
Dove si trova il problema? Se mi dai solo il codice non posso aiutarti!
aaa
18/07/13 7:42
raffa505
ho trovato due nuove funzioni gethex e make hex e ora funziona :D
aaa