Public Class Form1 Private udp1 As New UdpClient(1190) Private udp2 As New UdpClient() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load udp1.BeginReceive(AddressOf Receive, Nothing) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim buffer() As Byte = {0, 1, 2, 3} udp2.Send(buffer, 4, "localhost", 1190) End Sub Private Sub Receive(ByVal ar As IAsyncResult) Dim buffer() As Byte Dim ipe As IPEndPoint = Nothing buffer = udp1.EndReceive(ar, ipe) End Sub End Class
Private udp1 As New UdpClient(1190) Private udp2 As New UdpClient(1190)