#include <errno.h>

#define E2BIG [argument list too long]
#define EACCES [permission denied]
#define EADDRINUSE [address in use]
#define EADDRNOTAVAIL [address not available]
#define EAFNOSUPPORT [address family not supported]
#define EAGAIN [resource unavailable try again]
#define EALREADY [connection already in progress]
#define EBADF [bad file descriptor]
#define EBADMSG [bad message]
#define EBUSY [device or resource busy]
#define ECANCELED [operation canceled]
#define ECHILD [no child process]
#define ECONNABORTED [connection aborted]
#define ECONNREFUSED [connection refused]
#define ECONNRESET [connection reset]
#define EDEADLK [resource deadlock would occur]
#define EDESTADDRREQ [destination address required]
#define EDOM [argument out of domain]
#define EEXIST [file exists]
#define EFAULT [bad address]
#define EFBIG [file too large]
#define EHOSTUNREACH [host unreachable]
#define EIDRM [identifier removed]
#define EILSEQ [illegal byte sequence]
#define EINPROGRESS [operation in progress]
#define EINTR [interrupted]
#define EINVAL [invalid argument]
#define EIO [io error]
#define EISCONN [already connected]
#define EISDIR [is a directory]
#define ELOOP [too many synbolic link levels]
#define EMFILE [too many files open]
#define EMLINK [too many links]
#define EMSGSIZE [message size]
#define ENAMETOOLONG [filename too long]
#define ENETDOWN [network down]
#define ENETRESET [network reset]
#define ENETUNREACH [network unreachable]
#define ENFILE [too many files open in system]
#define ENOBUFS [no buffer space]
#define ENODATA [no message available]
#define ENODEV [no such device]
#define ENOENT [no such file or directory]
#define ENOEXEC [executable format error]
#define ENOLCK [no lock available]
#define ENOLINK [no link]
#define ENOMEM [not enough memory]
#define ENOMSG [no message]
#define ENOPROTOOPT [no protocol option]
#define ENOSPC [no space on device]
#define ENOSR [no stream resources]
#define ENOSTR [not a stream]
#define ENOSYS [function not supported]
#define ENOTCONN [not connected]
#define ENOTDIR [not a directory]
#define ENOTEMPTY [directory not empty]
#define ENOTRECOVERABLE [state not recoverable]
#define ENOTSOCK [not a socket]
#define ENOTSUP [not supported]
#define ENOTTY [inappropriate io control operation]
#define ENXIO [no such device or address]
#define EOPNOTSUPP [operation not supported]
#define EOTHER [other]
#define EOVERFLOW [value too large]
#define EOWNERDEAD [owner dead]
#define EPERM [operation not permitted]
#define EPIPE [broken pipe]
#define EPROTO [protocol error]
#define EPROTONOSUPPORT [protocol not supported]
#define EPROTOTYPE [wrong protocol type]
#define ERANGE [result out of range]
#define EROFS [read only file system]
#define ESPIPE [invalid seek]
#define ESRCH [no such process]
#define ETIME [stream timeout]
#define ETIMEDOUT [timed out]
#define ETXTBSY [text file busy]
#define EWOULDBLOCK [operation would block]
#define EXDEV [cross device link]

转载于:https://www.cnblogs.com/greencolor/archive/2012/02/28/2371337.html

帮我补全代码 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #define MAXLINE 4096 int main(int argc, char *argv[]) { int sockfd, n; // sockfd是客户端创建的socket描述字,客户端不需要区分监听listenfd和连接connfd。n为发送长度 char recvline[MAXLINE], sendline[MAXLINE]; // recvline暂时没用,sendline为即将发送的数据 struct sockaddr_in servaddr; //创建需要连接的服务端地址 if (argc != 2) { printf("usage: ./client <ipaddress>"); exit(0); } //设置运行时候需要输入的格式,执行文件+服务端ip地址 if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("create socket error:%s(errno:%d)\n", strerror(errno), errno); exit(0); } //创建socket描述字,因为客户端,只需要一次连接 memset(&servaddr, 0, sizeof(servaddr)); //先把当前连接的服务端地址全填充0 servaddr.sin_family = AF_INET; //目的服务端地址协议簇为ipv4 servaddr.sin_port = htons(6666); //设置端口号6666 if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0) { printf("inet_pton error for %s\n", argv[1]); exit(0); } //将目的服务端的地址,转换成网络地址,必须转换成网络地址!!argv[0]是./client,argv[1]是服务端的地址 if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { printf("connect socket error:%s(errno:%d)\n", strerror(errno), errno); exit(0); } //创建连接,本机的socket通过服务端地址连接服务端,强转指针格式 printf("send msg to server:\n"); //连接上后输出发送信息到服务端 fgets(sendline, 4096, stdin); //标准输入流中获取需要发送的信息,存储到sendline字符数组中 if (send(sockfd, sendline, strlen(sendline), 0) < 0) { printf("send msg error:%s(errno:%d)\n", strerror(errno), errno); exit(0); } //发送信息,sendline buff中的信息 close(sockfd); //信息发送完关闭自己的sockfd,第一次挥手 exit(0); }
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值