"The requested address is not valid in its context."
Code:Try Dim ipAddress As IPAddress = IPAddress.Parse("192.168.0.4") Dim localEndPoint As New IPEndPoint(ipAddress, 1420) mySocket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) mySocket.Bind(localEndPoint) Dim szData As String = vbCr & vbLf Dim byData As Byte() = System.Text.Encoding.ASCII.GetBytes(szData) Dim sender1 As New IPEndPoint(IPAddress.Any, 0) Dim tmpRemote As EndPoint = DirectCast((sender1), EndPoint) mySocket.SendTo(byData, tmpRemote) recv = mySocket.ReceiveFrom(data, tmpRemote) TerminalTextBox.Text += "Message received from: " & tmpRemote.ToString() TerminalTextBox.Text += Encoding.ASCII.GetString(data, 0, recv) While True data = New Byte(1023) {} recv = mySocket.ReceiveFrom(data, tmpRemote) Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)) End While Catch se As SocketException MessageBox.Show(se.Message) End Try
Any ideas?![]()




Reply With Quote