1 #include "toys.h" 2 xsocket(int domain,int type,int protocol)3int xsocket(int domain, int type, int protocol) 4 { 5 int fd = socket(domain, type, protocol); 6 7 if (fd < 0) perror_exit("socket %x %x", type, protocol); 8 return fd; 9 } 10 xsetsockopt(int fd,int level,int opt,void * val,socklen_t len)11void xsetsockopt(int fd, int level, int opt, void *val, socklen_t len) 12 { 13 if (-1 == setsockopt(fd, level, opt, val, len)) perror_exit("setsockopt"); 14 } 15