Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
/* */ | ||
|
||
struct addrinfo | ||
{ | ||
int ai_flags; | ||
int ai_family; | ||
int ai_socktype; | ||
int ai_protocol; | ||
socklen_t ai_addrlen; | ||
struct sockaddr *ai_addr; | ||
char *ai_canonname; | ||
struct addrinfo *ai_next; | ||
}; | ||
|
||
extern int getaddrinfo(const char *name, const char *service, const struct addrinfo *req, struct addrinfo **pai); | ||
extern void freeaddrinfo(struct addrinfo *ai); | ||
extern int getnameinfo (struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags); | ||
const char *gai_strerror(int ecode); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
#define INET_ADDRSTRLEN 16 | ||
|
||
struct in_addr { | ||
unsigned long s_addr; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define POLLIN 1 | ||
#define POLLOUT 2 | ||
#define POLLNVAL 4 | ||
#define POLLERR 8 | ||
#define POLLHUP 16 | ||
|
||
struct pollfd { | ||
int fd; | ||
short events; | ||
short revents; | ||
}; | ||
|
||
int poll(struct pollfd *data, int num, int extra); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#include "sys/poll.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#ifndef _SYS_POLL_H | ||
#define _SYS_POLL_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define POLLIN 1 | ||
#define POLLOUT 2 | ||
#define POLLNVAL 4 | ||
#define POLLERR 8 | ||
#define POLLHUP 16 | ||
|
||
struct pollfd { | ||
int fd; | ||
short events; | ||
short revents; | ||
}; | ||
|
||
int poll(struct pollfd *data, int num, int extra); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
/* */ | ||
|
||
#define AF_UNSPEC 100 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
arlolra
Contributor
|
||
#define SOCK_STREAM 200 | ||
#define SOL_SOCKET 50 | ||
#define SO_ERROR 10 | ||
#define SOCK_DGRAM 20 | ||
#define SO_REUSEADDR 30 | ||
#define SO_SNDBUF 40 | ||
#define SO_RCVBUF 60 | ||
|
||
typedef int socklen_t; | ||
|
||
typedef unsigned int sa_family_t; | ||
|
@@ -11,4 +20,21 @@ struct sockaddr { | |
char sa_data[]; | ||
}; | ||
|
||
struct sockaddr_storage { | ||
sa_family_t ss_family; | ||
}; | ||
|
||
ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len); | ||
int getpeername(int socket, struct sockaddr *address, socklen_t *address_len); | ||
int getsockname(int socket, struct sockaddr *address, socklen_t *address_len); | ||
int socket(int domain, int type, int protocol); | ||
int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen); | ||
int listen(int sockfd, int backlog); | ||
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); | ||
int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen); | ||
int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen); | ||
ssize_t recv(int s, void *buf, size_t len, int flags); | ||
ssize_t send(int s, const void *buf, size_t len, int flags); | ||
int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen); | ||
ssize_t sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); | ||
|
Any reason
AF_UNSPEC
is100
and not0
?