当我创建那个套接字时,执行函数accept,但是这个函数会引起一个警告,我不知道为什么,有人能帮我吗?,我的代码片段是

serv_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
checkError( (serv_sock < 0), "cliente: no puedo abrir un socket TCP\n");
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(atoi(argv[1]));
serv_addr.sin_addr.s_addr=0;
bind(serv_sock, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
listen(serv_sock,5);
clilen = sizeof(cli_addr);
while(clilen > 0){
     sockfd = accept(serv_sock, (struct sockaddr *) &cli_addr, &clilen);

警告是:passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]

最佳答案

你的申报表在哪里?
应声明:

socklen_t clilen;

鉴于编译器警告,我相信您使用了:
int clilen;

关于c - C中的套接字问题(函数接受),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50882974/

10-13 09:48