libc: Add wrappers for listen(), connect(), and accept()
This commit is contained in:
parent
ec5b83ff01
commit
8b91b7acc0
@ -16,6 +16,15 @@ extern "C"
|
|||||||
/* Bind a socket to an address. */
|
/* Bind a socket to an address. */
|
||||||
int bind(int sockfd, struct sockaddr* addr, socklen_t addrlen);
|
int bind(int sockfd, struct sockaddr* addr, socklen_t addrlen);
|
||||||
|
|
||||||
|
/* Connect a socket to a remote address. */
|
||||||
|
int connect(int sockfd, struct sockaddr* addr, socklen_t addrlen);
|
||||||
|
|
||||||
|
/* Start listening on a socket. */
|
||||||
|
int listen(int sockfd, int backlog);
|
||||||
|
|
||||||
|
/* Wait for an incoming connection on a socket. */
|
||||||
|
int accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,4 +16,22 @@ extern "C"
|
|||||||
long rc = syscall(SYS_bind, sockfd, addr, addrlen);
|
long rc = syscall(SYS_bind, sockfd, addr, addrlen);
|
||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int connect(int sockfd, struct sockaddr* addr, socklen_t addrlen)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_connect, sockfd, addr, addrlen);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
|
int listen(int sockfd, int backlog)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_listen, sockfd, backlog);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
|
int accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_accept, sockfd, addr, addrlen);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user