을 청취하려고 할 때 발생하지 않는 코드 :아무것도 포트 난 그냥 미리 정의 된 port.here에서 수신 대기하는 매우 간단한 프로그램을 작성하기 위해 노력하고있어
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
int sockfd;
struct addrinfo hints,*res;
memset(&hints,0,sizeof(hints));
hints.ai_family=AF_UNSPEC;
hints.ai_socktype=SOCK_STREAM;
hints.ai_flags=AI_PASSIVE;
getaddrinfo(NULL,"5050",&hints,&res);
sockfd=socket(res->ai_family,res->ai_socktype,res->ai_protocol);
bind(sockfd,res->ai_addr,res->ai_addrlen); //returns 0(success)
listen(sockfd,1);//returns 0(success)
return 0;
}
하지만 어디서나 청취의 흔적이 없다 .i netstat -l 명령을 사용하여 프로그램이 수신 중인지 확인합니다.
들어 본 후 들어오는 연결을 처리 할 루프가 필요합니다. –