59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
#ifndef NX_SOCKET_H
|
|
#define NX_SOCKET_H
|
|
|
|
#include "nx_types.h"
|
|
#include "nx_buf.h"
|
|
#include "nx_sockaddr.h"
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifdef MSG_NOSIGNAL
|
|
#define NX_SOCK_MSG_NOSIGNAL MSG_NOSIGNAL
|
|
#else
|
|
#define NX_SOCK_MSG_NOSIGNAL 0
|
|
#endif
|
|
|
|
int nx_socket(int domain, int type, int protocol);
|
|
|
|
int nx_set_nonblock(int fd, int on);
|
|
|
|
int nx_set_cloexec(int fd, int on);
|
|
|
|
int nx_set_reuseaddr(int fd, int on);
|
|
|
|
int nx_set_nosigpipe(int fd, int on);
|
|
|
|
int nx_socket_nosigpipe(void);
|
|
|
|
int nx_set_timeouts(int fd, int timeout_ms);
|
|
|
|
int nx_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
|
|
|
|
int nx_listen(int fd, int backlog);
|
|
|
|
int nx_accept(int fd, struct sockaddr_storage *peer, socklen_t *peerlen);
|
|
|
|
int nx_connect_timeout(int fd, const struct sockaddr *addr, socklen_t addrlen,
|
|
int timeout_ms);
|
|
|
|
int nx_listen_unix(const char *path, int backlog, int *abstract_out);
|
|
|
|
int nx_connect_unix(const char *path);
|
|
|
|
ssize_t nx_recv(int fd, void *buf, size_t n, int flags);
|
|
ssize_t nx_send(int fd, const void *buf, size_t n, int flags);
|
|
|
|
int nx_send_all(int fd, const void *buf, size_t n, int flags);
|
|
|
|
ssize_t nx_recv_line(int fd, nx_buf *scratch, char *line, size_t limit);
|
|
|
|
void nx_close(int *fd);
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif
|