Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a multithread(with Backgroundworker) TCP Server which is developed by VB.NET. It works very good when client and server at same machine. But when i connect to server from another computer which is at same LAN it works different. At this case it works good until i start to send messages consecutively (3-4 messages at a second). I send :
and server gets this messages such :
HiHiHi
It's very interesting that this issue occurs only when client is at other computer at LAN.
Here is my listen Sub :
Sub listen_port6(ByVal b As BackgroundWorker)
Dim server As TcpListener
server = Nothing
Dim port As Int32 = 8085
server = New TcpListener(IP, port)
server.Start()
Dim bytes(1024) As Byte
Dim data As String = Nothing
While True
Dim client As Sockets.TcpClient = server.AcceptTcpClient()
Dim ipend As Net.IPEndPoint = client.Client.RemoteEndPoint
PublicIP = ""
If Not ipend Is Nothing Then
PublicIP = ipend.Address.ToString
End If
b.ReportProgress(1)
Dim stream As NetworkStream = client.GetStream()
Dim i As Int32
Dim k As Short
For k = 0 To 1024
bytes(k) = 0
i = stream.Read(bytes, 0, bytes.Length)
While (i <> 0)
data = ""
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
Debug.Print(data)
i = stream.Read(bytes, 0, bytes.Length)
End While
client.Close()
End While
Catch errore As Exception
Error_Print(errore.Message)
Finally
server.Stop()
End Try
End Sub
Thanks in advance
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.