Use const pointers when possible
Sending data only require to read the input buffer, so declare it const.
This commit is contained in:
parent
6323f3974f
commit
b2b5404883
2 changed files with 4 additions and 4 deletions
|
@ -82,11 +82,11 @@ ssize_t net_recv_all(socket_t socket, void *buf, size_t len) {
|
||||||
return recv(socket, buf, len, MSG_WAITALL);
|
return recv(socket, buf, len, MSG_WAITALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t net_send(socket_t socket, void *buf, size_t len) {
|
ssize_t net_send(socket_t socket, const void *buf, size_t len) {
|
||||||
return send(socket, buf, len, 0);
|
return send(socket, buf, len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t net_send_all(socket_t socket, void *buf, size_t len) {
|
ssize_t net_send_all(socket_t socket, const void *buf, size_t len) {
|
||||||
ssize_t w;
|
ssize_t w;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
w = send(socket, buf, len, 0);
|
w = send(socket, buf, len, 0);
|
||||||
|
|
|
@ -26,8 +26,8 @@ socket_t net_accept(socket_t server_socket);
|
||||||
// the _all versions wait/retry until len bytes have been written/read
|
// the _all versions wait/retry until len bytes have been written/read
|
||||||
ssize_t net_recv(socket_t socket, void *buf, size_t len);
|
ssize_t net_recv(socket_t socket, void *buf, size_t len);
|
||||||
ssize_t net_recv_all(socket_t socket, void *buf, size_t len);
|
ssize_t net_recv_all(socket_t socket, void *buf, size_t len);
|
||||||
ssize_t net_send(socket_t socket, void *buf, size_t len);
|
ssize_t net_send(socket_t socket, const void *buf, size_t len);
|
||||||
ssize_t net_send_all(socket_t socket, void *buf, size_t len);
|
ssize_t net_send_all(socket_t socket, const void *buf, size_t len);
|
||||||
// how is SHUT_RD (read), SHUT_WR (write) or SHUT_RDWR (both)
|
// how is SHUT_RD (read), SHUT_WR (write) or SHUT_RDWR (both)
|
||||||
SDL_bool net_shutdown(socket_t socket, int how);
|
SDL_bool net_shutdown(socket_t socket, int how);
|
||||||
SDL_bool net_close(socket_t socket);
|
SDL_bool net_close(socket_t socket);
|
||||||
|
|
Loading…
Reference in a new issue