1
0
mirror of https://github.com/fumiama/simple-http-server.git synced 2026-06-17 01:40:33 +08:00

优化缩进

This commit is contained in:
源文雨
2021-06-09 13:22:46 +08:00
parent 2ff2293882
commit 92a6a33380

View File

@@ -453,22 +453,18 @@ static int startup(uint16_t *port) {
bzero(&(name.sin_zero), 8); bzero(&(name.sin_zero), 8);
httpd = socket(AF_INET, SOCK_STREAM, 0); httpd = socket(AF_INET, SOCK_STREAM, 0);
#endif #endif
if (httpd == -1) if(httpd == -1) error_die("socket");
error_die("socket"); if(bind(httpd,(struct sockaddr *)&name, struct_len) < 0) error_die("bind");
if (bind(httpd, (struct sockaddr *)&name, struct_len) < 0)
error_die("bind");
/* if dynamically allocating a port */ /* if dynamically allocating a port */
if(*port == 0) { if(*port == 0) {
if (getsockname(httpd, (struct sockaddr *)&name, &struct_len) == -1) if(getsockname(httpd,(struct sockaddr *)&name, &struct_len) == -1) error_die("getsockname");
error_die("getsockname");
#ifdef LISTEN_ON_IPV6 #ifdef LISTEN_ON_IPV6
*port = ntohs(name.sin6_port); *port = ntohs(name.sin6_port);
#else #else
*port = ntohs(name.sin_port); *port = ntohs(name.sin_port);
#endif #endif
} }
if (listen(httpd, 5) < 0) if(listen(httpd, 5) < 0) error_die("listen");
error_die("listen");
return(httpd); return(httpd);
} }