mirror of
https://github.com/fumiama/simple-http-server.git
synced 2026-06-27 08:10:25 +08:00
优化缩进
This commit is contained in:
12
server.c
12
server.c
@@ -453,22 +453,18 @@ static int startup(uint16_t *port) {
|
||||
bzero(&(name.sin_zero), 8);
|
||||
httpd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
#endif
|
||||
if (httpd == -1)
|
||||
error_die("socket");
|
||||
if (bind(httpd, (struct sockaddr *)&name, struct_len) < 0)
|
||||
error_die("bind");
|
||||
if(httpd == -1) error_die("socket");
|
||||
if(bind(httpd,(struct sockaddr *)&name, struct_len) < 0) error_die("bind");
|
||||
/* if dynamically allocating a port */
|
||||
if(*port == 0) {
|
||||
if (getsockname(httpd, (struct sockaddr *)&name, &struct_len) == -1)
|
||||
error_die("getsockname");
|
||||
if(getsockname(httpd,(struct sockaddr *)&name, &struct_len) == -1) error_die("getsockname");
|
||||
#ifdef LISTEN_ON_IPV6
|
||||
*port = ntohs(name.sin6_port);
|
||||
#else
|
||||
*port = ntohs(name.sin_port);
|
||||
#endif
|
||||
}
|
||||
if (listen(httpd, 5) < 0)
|
||||
error_die("listen");
|
||||
if(listen(httpd, 5) < 0) error_die("listen");
|
||||
return(httpd);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user