Dim gpsocket As Socket
gpsocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim localEndPoint As New IPEndPoint(IPAddress.Parse(Trim(socketclient_ip_txt.Text)), Trim(socketclient_port_txt.Text))
gpsocket.Connect(localEndPoint)
gpsocket.Send(Encoding.ASCII.GetBytes(str))
Dim stringData As String
Do While (True)
Dim data(1024000) As Byte
gpsocket.Receive(data)
stringData = Encoding.UTF8.GetString(data)
If Not (String.IsNullOrWhiteSpace(stringData)) Then
Exit Do
End If
Loop
dealdata(stringData)
转载请注明出处:
未经允许不得转载:lxfamn » 【vb.net】Socket做从站接收返回信息