Formatting ......
This commit is contained in:
parent
5392c8e418
commit
655b310328
2 changed files with 67 additions and 66 deletions
|
@ -15,8 +15,7 @@
|
|||
// Round size up to nearest power-of-two order
|
||||
static int size_to_order(size_t size) {
|
||||
int order = MIN_ORDER;
|
||||
while ((1U << order) < size)
|
||||
order++;
|
||||
while ((1U << order) < size) order++;
|
||||
return order;
|
||||
}
|
||||
|
||||
|
|
12
sock.c
12
sock.c
|
@ -1,10 +1,10 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
// Get TCP protocol entry
|
||||
|
@ -29,7 +29,8 @@ int main(void) {
|
|||
};
|
||||
|
||||
// Bind socket
|
||||
if (bind(server_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
|
||||
if (bind(server_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) <
|
||||
0) {
|
||||
perror("bind failed");
|
||||
close(server_fd);
|
||||
return EXIT_FAILURE;
|
||||
|
@ -47,7 +48,8 @@ int main(void) {
|
|||
// Accept one client connection
|
||||
struct sockaddr_in client_addr;
|
||||
socklen_t client_len = sizeof(client_addr);
|
||||
int client_fd = accept(server_fd, (struct sockaddr *)&client_addr, &client_len);
|
||||
int client_fd =
|
||||
accept(server_fd, (struct sockaddr *)&client_addr, &client_len);
|
||||
if (client_fd < 0) {
|
||||
perror("accept failed");
|
||||
close(server_fd);
|
||||
|
|
Loading…
Add table
Reference in a new issue