Home > other >  Questions about the socket message reads
Questions about the socket message reads

Time:10-10

Doing a client for handling the server from the message, see sample on the UNIX network programming is to make a buffer zone, while loop reads sockfd,
Each message contains a header and a message, every time want to fall excuse me read messages, will happen to read only a message?
If the server is continuous from multiple messages, it is read, or an article a read?
Message to deal with because while receiving messages in the process, process the messages from several servers, this is what kind of situation?

CodePudding user response:

Not just, possible to glue the situation of the package, the need to define the data structure, such as agreed with "a complete news & lt; BEGIN>" To start, "& lt; END>" The end, and also need to advance the appointment data structures, in this case, the data is connected & lt; BEGIN> 11 # aa# 532342 & lt; END> 12 # ab# 52324123 & lt; END> . , meet & lt; END> For processing

CodePudding user response:

Due to network instability, so can't guarantee a receive, may also be an a or a, interval more than receiving. So, for network turmoil of the solution is to build a circular buffer, then according to the message structure one by one.
  • Related