vb.net中用UdpClient接收和发送的问题,求解?
' 向服务器发送数据(发送代码)
Public Function MDISendData(ByVal IP As String, ByVal Sport As Integer, ByVal Rport As Integer, ByVal Sdata As String) As Boolean
Dim locaipendpoint As New IPEndPoint(IPAddress.Parse(IP), Rport)
Try
If Not Udp1 Is Nothing Then
Udp1 = Nothing
End If
Udp1 = New UdpClient(Rport)
Udp1.Connect(locaipendpoint)
Dim sendbytes As Byte() = Encoding.UTF8.GetBytes(Sdata)
Udp1.Send(sendbytes, sendbytes.Length)
If Not Udp1 Is Nothing Then
Udp1.Close()
Udp1 = Nothing
End If
Catch ex As Exception
Throw ex
Return False
End Try
Return True
End Function
以上为发送,各位高手,请问如何写接收数据的代码,要用到套接字,求解?