comparison tcp-accept.c @ 1403:ae6887d9ab46

rename hidden variable in function tcp_acceptor() struct sockaddr_storage addr; char* addr = NULL;
author Francois Perrad <francois.perrad@gadz.org>
date Sat, 19 Nov 2016 15:07:42 +0100
parents 750ec4ec4cbe
children 58a74cb829b8
comparison
equal deleted inserted replaced
1402:553c6bb80265 1403:ae6887d9ab46
53 } 53 }
54 54
55 static void tcp_acceptor(struct Listener *listener, int sock) { 55 static void tcp_acceptor(struct Listener *listener, int sock) {
56 56
57 int fd; 57 int fd;
58 struct sockaddr_storage addr; 58 struct sockaddr_storage sa;
59 socklen_t len; 59 socklen_t len;
60 char ipstring[NI_MAXHOST], portstring[NI_MAXSERV]; 60 char ipstring[NI_MAXHOST], portstring[NI_MAXSERV];
61 struct TCPListener *tcpinfo = (struct TCPListener*)(listener->typedata); 61 struct TCPListener *tcpinfo = (struct TCPListener*)(listener->typedata);
62 62
63 len = sizeof(addr); 63 len = sizeof(sa);
64 64
65 fd = accept(sock, (struct sockaddr*)&addr, &len); 65 fd = accept(sock, (struct sockaddr*)&sa, &len);
66 if (fd < 0) { 66 if (fd < 0) {
67 return; 67 return;
68 } 68 }
69 69
70 if (getnameinfo((struct sockaddr*)&addr, len, ipstring, sizeof(ipstring), 70 if (getnameinfo((struct sockaddr*)&sa, len, ipstring, sizeof(ipstring),
71 portstring, sizeof(portstring), 71 portstring, sizeof(portstring),
72 NI_NUMERICHOST | NI_NUMERICSERV) != 0) { 72 NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
73 m_close(fd); 73 m_close(fd);
74 return; 74 return;
75 } 75 }