}
+int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
+{
+ // Determine hostname
+ if( host )
+ {
+ if( hostlen == 0 )
+ return EAI_OVERFLOW;
+ host[0] = '\0';
+ if( !(flags & NI_NUMERICHOST) )
+ {
+ // Handle NI_NOFQDN
+ }
+ // Numeric hostname or the hostname was unresolvable
+ if( host[0] == '\0' )
+ {
+ if( (flags & NI_NAMEREQD) )
+ return EAI_NONAME;
+ }
+ }
+
+ // Determine service name
+ if( serv )
+ {
+ if( servlen == 0 )
+ return EAI_OVERFLOW;
+ serv[0] = '\0';
+ if( !(flags & NI_NUMERICSERV) )
+ {
+ // Handle NI_DGRAM
+ }
+ if( serv[0] == '\0' )
+ {
+
+ }
+ }
+ return EAI_SUCCESS;
+}
+
+
const char *gai_strerror(int errnum)
{
switch(errnum)
#define AI_ADDRCONFIG 0x004
#define AI_NUMERICHOST 0x008
+#define NI_NAMEREQD (1<<0)
+#define NI_DGRAM (1<<1)
+#define NI_NOFQDN (1<<2)
+#define NI_NUMERICHOST (1<<3)
+#define NI_NUMERICSERV (1<<4)
+
enum
{
EAI_SUCCESS,
EAI_NODATA,
EAI_NONAME,
EAI_SERVICE,
- EAI_SYSTEM
+ EAI_SYSTEM,
+ EAI_OVERFLOW
};
struct addrinfo
struct addrinfo *ai_next;
};
+extern int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
extern int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
extern void freeaddrinfo(struct addrinfo *res);
const char *gai_strerror(int errorcode);
+/*
+ * Acess2 POSIX Sockets Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * netinet/in.h
+ * - ?Addressing?
+ */
#ifndef _LIBPSOCKET__NETINET__IN_H_
#define _LIBPSOCKET__NETINET__IN_H_
--- /dev/null
+/*
+ * Acess2 POSIX Sockets Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * netinet/ip.h
+ * - ???
+ */
+#ifndef _LIBPSOCKET__NETINET__IP_H_
+#define _LIBPSOCKET__NETINET__IP_H_
+
+#endif
+
#define _SYS_SOCKETS_H_
#include <sys/types.h>
+#ifndef size_t
#include <stddef.h> // size_t
+#endif
#include <stdint.h> // uint32_t
typedef uint32_t socklen_t;
enum
{
SO_REUSEADDR,
- SO_LINGER
+ SO_LINGER,
+ SO_ERROR
+};
+
+// shutdown how
+enum
+{
+ SHUT_RD,
+ SHUT_WR,
+ SHUT_RDWR
};
/**
*/
extern int socket(int domain, int type, int protocol);
+/**
+ *
+ */
+extern int shutdown(int socket, int how);
+
/**
* \brief Bind a socket to an address
*/
extern int getsockname(int socket, struct sockaddr *addr, socklen_t *addrlen);
extern int getpeername(int socket, struct sockaddr *addr, socklen_t *addrlen);
+extern struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type);
+extern void sethostent(int stayopen);
+extern void endhostent(void);
+extern void herror(const char *s);
+extern const char *hstrerror(int err);
+extern struct hostent *gethostent(void);
+
#endif