wrappers.c

来自「this gives details of the network progra」· C语言 代码 · 共 38 行

C
38
字号
// Wrapper functions for Socket system calls.//// These functions assume any error is a fatal error!#include <stdio.h>	/* standard C i/o facilities */#include <stdlib.h>	/* needed for atoi() */#include <unistd.h>	/* Unix System Calls */#include <sys/types.h>	/* system data type definitions */#include <sys/socket.h> /* socket specific definitions */#include <netinet/in.h> /* INET constants and stuff */#include <arpa/inet.h>	/* IP address conversion stuff */int np_socket( int domain, int type, int protocol) {  int sk;  if ((sk = socket( PF_INET, SOCK_STREAM, 0 )) < 0) {    perror("Problem creating socket\n");    exit(1);  }  return(sk);}int np_bind(int sd, const struct sockaddr *addr, int addrlen) {  int retval;  if ((retval = bind(sd, addr, addrlen))<0) {    perror("Problem binding\n");    exit(1);  }  return(retval);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?