What is the correct way of reading from a TCP socket in C/C++?

前端 未结 8 1454
后悔当初
后悔当初 2020-11-28 04:33

Here\'s my code:

// Not all headers are relevant to the code snippet.
#include 
#include 
#include 
#in         


        
8条回答
  •  一生所求
    2020-11-28 04:44

    Just to add to things from several of the posts above:

    read() -- at least on my system -- returns ssize_t. This is like size_t, except is signed. On my system, it's a long, not an int. You might get compiler warnings if you use int, depending on your system, your compiler, and what warnings you have turned on.

提交回复
热议问题