【vb.net】Socket做从站接收返回信息

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)

转载请注明出处:

转载自http://lxfamn.cn/blog

未经允许不得转载:lxfamn » 【vb.net】Socket做从站接收返回信息

赞 (0) 打赏

置顶推荐

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏