我无法解决的错误

时间:2019-06-28 16:12:03

标签: c server client-server

我对解决两个代码错误有疑问。我使用nBytes变量,但是编译器说我不在任何地方使用。第二个引用指针。

server2.c:90:36: warning: pointer targets in passing argument 6 of ‘recvfrom’ differ in signedness [-Wpointer-sign]
   (struct sockaddr*)&addr_con, &addrlen);
                                ^
In file included from /usr/include/netinet/in.h:23:0,
                 from /usr/include/arpa/inet.h:22,
                 from server2.c:2:
/usr/include/x86_64-linux-gnu/sys/socket.h:163:16: note: expected ‘socklen_t * restrict {aka unsigned int * restrict}’ but argument is of type ‘int *’
 extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
                ^~~~~~~~
server2.c:59:14: warning: variable ‘nBytes’ set but not used [-Wunused-but-set-variable]
  int sockfd, nBytes;
              ^~~~~~

有一个代码:

    90:36 nBytes = recvfrom(sockfd, net_buf, 
                    NET_BUF_SIZE, sendrecvflag, 
                    (struct sockaddr*)&addr_con, &addrlen); 

    56:14 int sockfd, nBytes; 

有什么建议吗?

0 个答案:

没有答案