mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:47:45 +00:00
Net: Add a basic sys$shutdown() implementation
Calling shutdown prevents further reads and/or writes on a socket. We should do a few more things based on the type of socket, but this initial implementation just puts the basic mechanism in place. Work towards #428.
This commit is contained in:
parent
a3f39fe789
commit
2b0b7cc5a4
8 changed files with 60 additions and 2 deletions
|
@ -62,6 +62,12 @@ int connect(int sockfd, const sockaddr* addr, socklen_t addrlen)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int shutdown(int sockfd, int how)
|
||||
{
|
||||
int rc = syscall(SC_shutdown, sockfd, how);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
ssize_t sendto(int sockfd, const void* data, size_t data_length, int flags, const struct sockaddr* addr, socklen_t addr_length)
|
||||
{
|
||||
Syscall::SC_sendto_params params { sockfd, { data, data_length }, flags, addr, addr_length };
|
||||
|
|
|
@ -49,6 +49,10 @@ __BEGIN_DECLS
|
|||
#define SOCK_NONBLOCK 04000
|
||||
#define SOCK_CLOEXEC 02000000
|
||||
|
||||
#define SHUT_RD 1
|
||||
#define SHUT_WR 2
|
||||
#define SHUT_RDWR 3
|
||||
|
||||
#define IPPROTO_IP 0
|
||||
#define IPPROTO_ICMP 1
|
||||
#define IPPROTO_TCP 6
|
||||
|
@ -81,6 +85,7 @@ int bind(int sockfd, const struct sockaddr* addr, socklen_t);
|
|||
int listen(int sockfd, int backlog);
|
||||
int accept(int sockfd, struct sockaddr*, socklen_t*);
|
||||
int connect(int sockfd, const struct sockaddr*, socklen_t);
|
||||
int shutdown(int sockfd, int how);
|
||||
ssize_t send(int sockfd, const void*, size_t, int flags);
|
||||
ssize_t sendto(int sockfd, const void*, size_t, int flags, const struct sockaddr*, socklen_t);
|
||||
ssize_t recv(int sockfd, void*, size_t, int flags);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue