Skip to content

Instantly share code, notes, and snippets.

@mgood7123
Last active November 30, 2022 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgood7123/1ec93a07f36d88612a1233c1e1c503d2 to your computer and use it in GitHub Desktop.
Save mgood7123/1ec93a07f36d88612a1233c1e1c503d2 to your computer and use it in GitHub Desktop.
// send data
while (connection->out.head - connection->out.tail > 0) {
ring_buffer_get_iov(&connection->out, iov, &count);
if (len == SOCKET_ERROR)
return -1;
struct wl_ring_buffer * buffer = &connection->out;
do {
len = send(connection->fd, ring_buffer_size(buffer), sizeof(size_t), 0);
} while (len == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
do {
len = send(connection->fd, connection->out.data, ring_buffer_size(buffer), 0);
} while (len == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
connection->out.tail += len;
}
connection->want_flush = 0;
return connection->out.head - tail;
// ...
// recieve data
size_t ring_buf_len;
do {
len = recv(connection->fd, &ring_buf_len, sizeof(size_t), 0);
} while (len == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
RING_BUFFER_TYPE * ring_buf_data = zalloc(ring_buf_len);
do {
len = recv(connection->fd, ring_buf_data, ring_buf_len, 0);
} while (len == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
if (len <= 0)
return len;
connection->in.head += len;
return wl_connection_pending_input(connection);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment