|
这是源程序:
- #include "unp.h"
- int
- main(int argc,char **argv)
- {
- int sockfd,n;
- char recvline[MAXLINE+1];
- struct sockaddr_in servaddr;
- if(argc != 2) {
- printf("Usage : %s <IPaddress>\n",argv[0]);
- return(1);
- }
- if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) {
- printf("create socket error\n");
- return(1);
- }
- bzero(&servaddr,sizeof(servaddr));
- servaddr.sin_family=AF_INET;
- servaddr.sin_port=htons(13);
- if(inet_pton(AF_INET,argv[1],&servaddr.sin_addr) <= 0) {
- printf("inet_pton error\n");
- retrun(1);
- }
- if(connect(sockfd,(struct sockaddr *)&servaddr,sieof(servaddr))<0) {
- printf("connect error\n");
- return(1);
- }
- while((n=read(sockfd,recvline,MAXLINE))>0) {
- recvline[n]=0; /* null terminate */
- if(fputs(recvline,stdout) == EOF ) {
- printf("fputs error\n");
- return(1);
- }
- }
- if(n<0) {
- printf("read error\n");
- return(1);
- }
- return(0);
- }
复制代码
un.h我是照着书抄的,估计没问题。以下是错误。@@@@@@
- In file included from daytimetcpcli.c:1:
- /usr/include/unp.h:10: syntax error before `/'
- In file included from /usr/include/sys/inttypes.h:9,
- from /usr/include/sys/types.h:48,
- from /usr/include/unp.h:15,
- from daytimetcpcli.c:1:
- /usr/include/machine/ansi.h:146: syntax error before `__int64_t'
- In file included from /usr/include/sys/types.h:48,
- from /usr/include/unp.h:15,
- from daytimetcpcli.c:1:
- /usr/include/sys/inttypes.h:14: syntax error before `int64_t'
- /usr/include/sys/inttypes.h:14: warning: data definition has no type or storage class
- In file included from /usr/include/sys/types.h:49,
- from /usr/include/unp.h:15,
- from daytimetcpcli.c:1:
- /usr/include/machine/types.h:51: syntax error before `vm_ooffset_t'
- /usr/include/machine/types.h:51: warning: data definition has no type or storage class
- In file included from /usr/include/unp.h:15,
- from daytimetcpcli.c:1:
- /usr/include/sys/types.h:66: syntax error before `quad_t'
- /usr/include/sys/types.h:66: warning: data definition has no type or storage class
- /usr/include/sys/types.h:67: syntax error before `*'
- /usr/include/sys/types.h:67: warning: data definition has no type or storage class
- /usr/include/sys/types.h:82: syntax error before `off_t'
- /usr/include/sys/types.h:82: warning: data definition has no type or storage class
- /usr/include/sys/types.h:84: syntax error before `rlim_t'
- /usr/include/sys/types.h:84: warning: data definition has no type or storage class
- In file included from /usr/include/unp.h:15,
- from daytimetcpcli.c:1:
- /usr/include/sys/types.h:198: syntax error before `off_t'
- /usr/include/sys/types.h:202: syntax error before `lseek'
- /usr/include/sys/types.h:202: syntax error before `off_t'
- /usr/include/sys/types.h:202: warning: data definition has no type or storage class
- /usr/include/sys/types.h:206: syntax error before `off_t'
- /usr/include/sys/types.h:210: syntax error before `off_t'
- In file included from /usr/include/unp.h:16,
- from daytimetcpcli.c:1:
- /usr/include/sys/socket.h:191: syntax error before `int64_t'
- /usr/include/sys/socket.h:451: syntax error before `off_t'
- In file included from /usr/include/unp.h:17,
- from daytimetcpcli.c:1:
- /usr/include/sys/time.h:147: syntax error before `int64_t'
- In file included from /usr/include/unp.h:22,
- from daytimetcpcli.c:1:
- /usr/include/fcntl.h:181: syntax error before `off_t'
- In file included from /usr/include/unp.h:25,
- from daytimetcpcli.c:1:
- /usr/include/stdio.h:55: syntax error before `fpos_t'
- /usr/include/stdio.h:55: warning: data definition has no type or storage class
- /usr/include/stdio.h:110: syntax error before `fpos_t'
- /usr/include/stdio.h:127: syntax error before `fpos_t'
- /usr/include/stdio.h:207: syntax error before `fpos_t'
- /usr/include/stdio.h:217: syntax error before `*'
- /usr/include/stdio.h:306: syntax error before `__int64_t'
- /usr/include/stdio.h:307: syntax error before `ftello'
- /usr/include/stdio.h:307: warning: data definition has no type or storage class
- /usr/include/stdio.h:339: syntax error before `fpos_t'
- /usr/include/stdio.h:339: syntax error before `fpos_t'
- /usr/include/stdio.h:339: `funopen' declared as function returning a function
- In file included from /usr/include/unp.h:26,
- from daytimetcpcli.c:1:
- /usr/include/stdlib.h:186: syntax error before `strtoq'
- /usr/include/stdlib.h:186: warning: data definition has no type or storage class
- In file included from /usr/include/unp.h:28,
- from daytimetcpcli.c:1:
- /usr/include/sys/stat.h:99: syntax error before `off_t'
- /usr/include/sys/stat.h:105: syntax error before `int64_t'
- /usr/include/sys/stat.h:129: syntax error before `off_t'
- /usr/include/sys/stat.h:134: syntax error before `int64_t'
- In file included from /usr/include/unp.h:30,
- from daytimetcpcli.c:1:
- /usr/include/unistd.h:135: syntax error before `off_t'
- /usr/include/unistd.h:143: syntax error before `off_t'
- /usr/include/unistd.h:145: syntax error before `off_t'
- /usr/include/unistd.h:186: syntax error before `__syscall'
- /usr/include/unistd.h:186: syntax error before `...'
- /usr/include/unistd.h:186: warning: data definition has no type or storage class
- In file included from daytimetcpcli.c:1:
- /usr/include/unp.h:376: syntax error before `off_t'
复制代码
这一定在哪里出错里,要不然也不会错这么多阿。。。。。。:confused: :confused: :confused: :help |
|