MCPcopy Create free account
hub / github.com/crownengine/crown / read

Function read

src/core/network/socket.cpp:90–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 }
89
90 ReadResult read(SOCKET socket, void *data, u32 size)
91 {
92 CE_ENSURE(socket != INVALID_SOCKET);
93
94 ReadResult rr;
95 rr.error = ReadResult::SUCCESS;
96 rr.bytes_read = 0;
97
98 u32 to_read = size;
99
100 while (to_read > 0) {
101 int bytes_read = ::recv(socket
102 , (char *)data + rr.bytes_read
103 , to_read
104 , 0
105 );
106
107 if (bytes_read == SOCKET_ERROR) {
108 if (last_error() == WSAEWOULDBLOCK)
109 rr.error = ReadResult::WOULDBLOCK;
110 else if (last_error() == WSAETIMEDOUT)
111 rr.error = ReadResult::TIMEOUT;
112 else
113 rr.error = ReadResult::UNKNOWN;
114 return rr;
115 } else if (bytes_read == 0) {
116 rr.error = ReadResult::REMOTE_CLOSED;
117 return rr;
118 }
119
120 to_read -= bytes_read;
121 rr.bytes_read += bytes_read;
122 }
123
124 return rr;
125 }
126
127 WriteResult write(SOCKET socket, const void *data, u32 size)
128 {

Callers 9

readMethod · 0.70
read_nonblockMethod · 0.70
new_guidFunction · 0.50
callstackFunction · 0.50
watchMethod · 0.50
read_allMethod · 0.50
readMethod · 0.50
loadFunction · 0.50
updateMethod · 0.50

Calls 1

last_errorFunction · 0.85

Tested by

no test coverage detected