The first one
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "netinet/in.h"
#include "sys/socket.h"
#include "sys/types.h"
int main()
{
int listenfd,connfd;
if((listenfd=socket(AF_INET,SOCK_STREAM,0))==0);
printf("socket success!
");
struct sockaddr_in servaddr,cliaddr;
servaddr.sin_family=AF_INET;
servaddr.sin_port=htons(39894);
servaddr.sin_addr.s_addr=inet_addr("192.168.152.130");
if(bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr))==0)
printf("bind success!
");
if(listen(listenfd,10)==0)
printf("listen success!
");
int len=sizeof(cliaddr);
connfd=accept(listenfd,(struct sockaddr *)&cliaddr,&len);
printf("%d",connfd);
return 0;
}
ごみコード第一編、間に合いましょう.