2 #include <sys/socket.h>
4 #include <netinet/in.h>
15 struct sockaddr_in clientaddr
;
16 char recvline
[1000] = "abcdef";
18 if((fd
= socket(AF_INET
, SOCK_STREAM
, 0)) < 0)
19 perror("socket create error");
21 bzero(&clientaddr
, sizeof(clientaddr
));
22 clientaddr
.sin_family
= AF_INET
;
23 inet_aton("127.0.0.1",&(clientaddr
.sin_addr
));
24 clientaddr
.sin_port
= htons(1235);
26 if(connect(fd
, (struct sockaddr
*)&clientaddr
,sizeof(clientaddr
)) < 0)
27 perror("connect error");
29 while((n
= write(fd
, recvline
,6))>0){
30 printf("recvline = %s",recvline
);
35 perror("write error");