Incomplete messages (C# TCP/IP Client)

前端 未结 3 2002
独厮守ぢ
独厮守ぢ 2020-12-20 00:05

First of all, I\'m absolutely not a network programmer. What I try to do, is a very simple TCP/IP communication between a Java server and a C# client.

Java server:

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 00:15

    A message (any data, I mean), when sent through a socket, is divided into several packets. When printing each received packet, you don't see your whole message.

    You should define an end of message string (something like ".#."). Until you receive this sequence, you keep concatenating the messages you receive.

    This is what session protocols (that is, protocols that run on the top of TCP) do.

    Hope this helps.

    Regards, Calil

提交回复
热议问题