⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wrappers.c

📁 this gives details of the network programming
💻 C
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -