Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Threading
- Imports System.Net.Sockets
- Imports System.IO
- Imports System.Net
- Public Class Packets
- Shared Dim Client As UdpClient
- Shared Dim Rcv As IPEndPoint
- Public Shared Sub Main()
- Dim Thread As Thread = New Thread(New ThreadStart(AddressOf WaitForPackets))
- Dim Packet As String = "Client"
- Dim Data As Byte() = System.Text.Encoding.ASCII.GetBytes(Packet)
- Dim Host As String = "localhost"
- Rcv = New IPEndPoint(New IPAddress(0), 0)
- Client = New UdpClient(5001)
- Thread.Start()
- Console.WriteLine("Packet envoyer à " & Host & ".")
- Client.Send(Data, Data.Length, Host, 5000)
- Console.WriteLine("Le packet " & Packet & " est envoyer avec succès !")
- End Sub
- Shared Public Sub PacketTime()
- While True
- Dim Data As Byte() = Client.Receive(Rcv)
- Console.WriteLine("Packet reçu :" & _
- vbCrLf & "Taille : " & Data.Length & vbCrLf & _
- System.Text.Encoding.ASCII.GetString(Data))
- End While
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment