|
我编译了一个下面这个服务端程序:
main()
{
int sockfd,new_fd;
struct sockaddr_in srv_addr; /* my address information */
struct sockaddr_in cli_addr; /* connector's address information */
int nbytes;
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("socket");
exit(1);
}
srv_addr.sin_family = AF_INET; /* host byte order */
srv_addr.sin_port = htons(MYPORT); /* short, network byte order */
srv_addr.sin_addr.s_addr =htonl(INADDR_ANY); /* auto-fill with my IP */
bzero(&(srv_addr.sin_zero), ; /* zero the rest of the struct */
if (bind(sockfd, (struct sockaddr *)&srv_addr,
sizeof(struct sockaddr)) == -1) {
perror("bind error");
exit(1);
}
if(listen(sockfd,BACKLOG)==-1){
perror("listen error");
exit(1);
}
for(;;){
nbytes = sizeof(struct sockaddr_in);
if ((new_fd=accept(sockfd,(struct sockaddr *)&cli_addr,
&nbytes)) == -1) {
perror("accept error");
continue;
}
printf("server:got packet from %s\n",inet_ntoa(cli_addr.sin_addr));
if(write(new_fd,"hello,network! \n",14)==-1)
perror("write error");
close(new_fd);
}
close(sockfd);
}
在linux 下运行后出现:listen error:program not supported
请问我这问题是出在哪儿??如果我要发送文件夹能用这个程序嘛??
小弟不才,请大虾赐教!!!!! |
|