1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Tester.Main()
End Sub
End Class
Public Class Tester
Public Shared Sub Main()
Dim client1 As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
Dim server1 As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
Dim MyIP As IPAddress
Dim bytes2(255) As Byte
Dim Port1 As Integer = 900
Dim port2 As Integer = 900
MyIP = IPAddress.Parse("127.0.0.1")
Dim server2 As New IPEndPoint(MyIP, Port1)
Dim client2 As New IPEndPoint(MyIP, port2)
client1.Bind(client2)
client1.ReceiveFrom(bytes2, server2)
client1.Close()
End Sub
End Class |