Skip to content

Commit

Permalink
socket header stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Oct 6, 2011
1 parent 5e4a111 commit ce6b7ea
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion system/include/libc/sys/unistd.h
Expand Up @@ -223,7 +223,7 @@ int _EXFUN(truncate, (const char *, off_t __length));
#endif
#endif

#if defined(__CYGWIN__) || defined(__rtems__)
#if defined(EMSCRIPTEN) || defined(__CYGWIN__) || defined(__rtems__)
int _EXFUN(getdtablesize, (void));
int _EXFUN(setdtablesize, (int));
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
Expand Down
1 change: 1 addition & 0 deletions system/include/net/arpa/inet.h
Expand Up @@ -4,3 +4,4 @@ uint32_t ntohl(uint32_t netlong);

uint16_t ntohs(uint16_t netshort);

int inet_aton(const char *cp, struct in_addr *addr);
18 changes: 17 additions & 1 deletion system/include/net/netdb.h
@@ -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);

2 changes: 2 additions & 0 deletions system/include/net/netinet/in.h
@@ -1,4 +1,6 @@

#define INET_ADDRSTRLEN 16

struct in_addr {
unsigned long s_addr;
};
Expand Down
22 changes: 1 addition & 21 deletions system/include/poll.h
@@ -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"

28 changes: 28 additions & 0 deletions system/include/sys/poll.h
@@ -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

26 changes: 26 additions & 0 deletions system/include/sys/socket.h
@@ -1,5 +1,14 @@
/* */

#define AF_UNSPEC 100

This comment has been minimized.

Copy link
@arlolra

arlolra Apr 4, 2013

Contributor

Any reason AF_UNSPEC is 100 and not 0?

This comment has been minimized.

Copy link
@kripken

kripken Apr 5, 2013

Author Member

None. Is there a reason it should be 0?

This comment has been minimized.

Copy link
@arlolra

arlolra Apr 5, 2013

Contributor

I suppose not, though it is on most platforms. The software I'm compiling relies on it being 0. Selfishness, is that a reason?

This comment has been minimized.

Copy link
@kripken

kripken Apr 9, 2013

Author Member

Enough, I guess ;) I would accept a pull request to change this.

This comment has been minimized.

Copy link
@arlolra

arlolra Apr 9, 2013

Contributor

Thanks. It's in #1045

#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;
Expand All @@ -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);

0 comments on commit ce6b7ea

Please sign in to comment.