Created
May 17, 2010 13:03
-
-
Save madx/403733 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#ifndef NETKIT_H_ | |
#define NETKIT_H_ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <sys/wait.h> | |
#include <fcntl.h> | |
#include <sys/socket.h> | |
#include <sys/un.h> | |
#include <netinet/ip.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
#include <signal.h> | |
#include <sys/time.h> | |
#include <time.h> | |
#include <errno.h> | |
#ifndef UNIX_PATH_MAX | |
#define UNIX_PATH_MAX 108 | |
#endif | |
#if __STDC_VERSION__ < 199901L | |
# if __GNUC__ >= 2 | |
# define __func__ __FUNCTION__ | |
# else | |
# define __func__ "<unknown>" | |
# endif | |
#endif | |
/* Prints the error with perror and exit with status EXIT_FAILURE */ | |
void nk_perror (const char *s); | |
/* Fork and returns the pid or stop with perror_ if it failed */ | |
pid_t nk_fork (); | |
/* Calls pipe and exit with perror_ if it failed */ | |
void nk_pipe (int fd[2]); | |
/* Sets a signal handler for <sig> */ | |
int nk_signal (int sig, void (*h)(int), int options); | |
/* Socket helpers */ | |
int nk_socket (int domain, int type, int protocol); | |
int nk_socket_inet (int type); | |
int nk_socket_unix (int type); | |
int nk_read_sock (int socket, void *buf, size_t count); | |
int nk_write_sock (int socket, void *buf, size_t count); | |
void nk_addr_inet (struct sockaddr_in *sockaddr, sa_family_t family, in_port_t port, uint32_t addr); | |
/* Unix Domain helpers */ | |
int nk_bind_unix (int sock, struct sockaddr_un *addr); | |
int nk_sendto_unix (int sock, void *buf, size_t len, struct sockaddr_un *addr); | |
int nk_recvfrom_unix (int sock, void *buf, size_t len, struct sockaddr_un *addr); | |
int nk_connect_unix (int sock, struct sockaddr_un *addr); | |
int nk_accept_unix (int sock, struct sockaddr_un *addr); | |
/* Inet domain Helpers */ | |
int nk_bind_inet (int sock, struct sockaddr_in *addr); | |
int nk_sendto_inet (int sock, void *buf, size_t len, struct sockaddr_in *addr); | |
int nk_recvfrom_inet (int sock, void *buf, size_t len, struct sockaddr_in *addr); | |
int nk_connect_inet (int sock, struct sockaddr_in *addr); | |
int nk_accept_inet (int sock, struct sockaddr_in *addr); | |
int nk_getsockname_inet (int sock, struct sockaddr_in *addr); | |
char *nk_adrtoa_inet (struct sockaddr_in *addr); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment