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

Function write

src/core/network/socket.cpp:127–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 WriteResult write(SOCKET socket, const void *data, u32 size)
128 {
129 CE_ENSURE(socket != INVALID_SOCKET);
130
131 WriteResult wr;
132 wr.error = WriteResult::SUCCESS;
133 wr.bytes_wrote = 0;
134
135 u32 to_write = size;
136
137 while (to_write > 0) {
138 int bytes_wrote = ::send(socket
139 , (char *)data + wr.bytes_wrote
140 , to_write
141 , MSG_NOSIGNAL // Don't generate SIGPIPE, return EPIPE instead.
142 );
143
144 if (bytes_wrote == SOCKET_ERROR) {
145 if (last_error() == WSAEWOULDBLOCK)
146 wr.error = WriteResult::WOULDBLOCK;
147 else if (last_error() == WSAETIMEDOUT)
148 wr.error = WriteResult::TIMEOUT;
149 else if (last_error() == EPIPE)
150 wr.error = WriteResult::PIPE;
151 else
152 wr.error = WriteResult::UNKNOWN;
153 return wr;
154 } else if (bytes_wrote == 0) {
155 wr.error = WriteResult::REMOTE_CLOSED;
156 return wr;
157 }
158
159 to_write -= bytes_wrote;
160 wr.bytes_wrote += bytes_wrote;
161 }
162 return wr;
163 }
164
165 void set_blocking(SOCKET socket, bool blocking)
166 {

Callers 9

writeMethod · 0.70
write_nonblockMethod · 0.70
demangler_mainFunction · 0.50
callstack_shutdownFunction · 0.50
callstackFunction · 0.50
add_subdirectoriesMethod · 0.50
watchMethod · 0.50
scan_subdirectoriesMethod · 0.50
watchMethod · 0.50

Calls 1

last_errorFunction · 0.85

Tested by

no test coverage detected