mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:07:44 +00:00
Add support for socket send/receive timeouts.
Only the receive timeout is hooked up yet. You can change the timeout by calling setsockopt(..., SOL_SOCKET, SO_RCVTIMEO, ...). Use this mechanism to make /bin/ping report timeouts.
This commit is contained in:
parent
7bcd386338
commit
562663df7c
12 changed files with 212 additions and 12 deletions
|
@ -48,4 +48,18 @@ ssize_t recvfrom(int sockfd, void* buffer, size_t buffer_length, int flags, cons
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_size)
|
||||
{
|
||||
Syscall::SC_getsockopt_params params { sockfd, level, option, value, value_size };
|
||||
int rc = syscall(SC_getsockopt, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int setsockopt(int sockfd, int level, int option, const void* value, socklen_t value_size)
|
||||
{
|
||||
Syscall::SC_setsockopt_params params { sockfd, level, option, value, value_size };
|
||||
int rc = syscall(SC_setsockopt, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,11 @@ struct sockaddr_in {
|
|||
char sin_zero[8];
|
||||
};
|
||||
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_RCVTIMEO 1
|
||||
#define SO_SNDTIMEO 2
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
int bind(int sockfd, const sockaddr* addr, socklen_t);
|
||||
int listen(int sockfd, int backlog);
|
||||
|
@ -52,6 +57,8 @@ int accept(int sockfd, sockaddr*, socklen_t*);
|
|||
int connect(int sockfd, const sockaddr*, socklen_t);
|
||||
ssize_t sendto(int sockfd, const void*, size_t, int flags, const struct sockaddr*, socklen_t);
|
||||
ssize_t recvfrom(int sockfd, void*, size_t, int flags, const struct sockaddr*, socklen_t);
|
||||
int getsockopt(int sockfd, int level, int option, void*, socklen_t*);
|
||||
int setsockopt(int sockfd, int level, int option, const void*, socklen_t);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue