SpiecsEngine
 
Loading...
Searching...
No Matches

◆ ReadFd()

size_t Spices::Net::Buffer::ReadFd ( SOCKET fd,
int * saveErrno )

Read from Socket.

Parameters
[in]fdSOCKET.
[in,out]saveErrnoError value.
Returns
Returns read bytes.
Note
read api can only be used in linux, on windows use recv instead,

Definition at line 53 of file Buffer.cpp.

54 {
55 char buffer[65536] = {}; // 64k
56
57 int n = ::recv(fd, buffer, sizeof(buffer), 0);
58
59 if (n < 0)
60 {
61 *saveErrno = WSAGetLastError();
62 }
63 else
64 {
65 const std::string str(buffer, n);
66 Append(str.c_str(), str.size());
67 }
68
69 return n;
70 }
void Append(const std::string &msg)
Append Message to this buffer.
Definition Buffer.cpp:41

References Append().