All pastes #909609 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-02-19 09:57 UTC
rendered paste body
Dim GotByte As Boolean
Dim PingByte As String
Dim PingPacket As Datagram
Dim s As String
Dim SoldatPacket As Datagram



UDPSocket2 - Sub DataAvailable()
  SoldatPacket = UDPSocket2.Read
  SoldatPacket.Address = "127.0.0.1"
  SoldatPacket.Port = 23073
  UDPSocket1.Write(SoldatPacket)
  s = SoldatPacket.Data
  If Asc(Left(s, 1)) = 30 And GotByte = True Then
    PingPacket.Data.Split.Append(PingByte)
    PingPacket.Data.Split.Append(s.Right(1))
    PingPacket.Address = ServerField.Text
    PingPacket.Port = PortField.Text.Val
    UDPSocket2.Write(PingPacket)
  End If

UDPSocket1 - Sub DataAvailable()
  SoldatPacket = UDPSocket1.Read
  SoldatPacket.Address = ServerField.Text
  SoldatPacket.Port = PortField.Text.Val
  s = SoldatPacket.Data
  
  If Asc(Left(s, 1)) = 31 And GotByte = False Then
    PingByte = Str(SoldatPacket.Data.Left(1))
    UDPSocket2.Write(SoldatPacket)
    GotByte = True
  End If
  
  If Asc(Left(s, 1)) <> 31 Then
    UDPSocket2.Write(SoldatPacket)
  End If


Timer1 - Sub Action()
  UDPSocket1.Poll()
  UDPSocket2.Poll()