diff options
author | Christian Hesse <mail@eworm.de> | 2019-09-04 12:13:01 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-09-06 11:53:23 +0200 |
commit | a136e1b54c5b350ac631cf9a2f377cc9d8c5501a (patch) | |
tree | a8e38208b258efd954be78bf12cec705db192348 /udp514-journal.c | |
parent | aedd6f6551da38c90135c9b607143909981bf4b7 (diff) | |
download | udp514-journal-a136e1b54c5b350ac631cf9a2f377cc9d8c5501a.tar.gz udp514-journal-a136e1b54c5b350ac631cf9a2f377cc9d8c5501a.tar.zst |
use more descriptive variable names
Diffstat (limited to 'udp514-journal.c')
-rw-r--r-- | udp514-journal.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/udp514-journal.c b/udp514-journal.c index 5784491..1065b99 100644 --- a/udp514-journal.c +++ b/udp514-journal.c @@ -8,15 +8,15 @@ #include "udp514-journal.h" int main(int argc, char **argv) { - int s, n; + int sock, num; socklen_t len; struct sockaddr_in cliAddr, servAddr; char buffer[BUFFER_SIZE]; - const int y = 1; + const int opt_val = 1; unsigned int count = 0; /* open socket */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("could not open socket"); return EXIT_FAILURE; } @@ -25,8 +25,8 @@ int main(int argc, char **argv) { servAddr.sin_family = AF_INET; servAddr.sin_addr.s_addr = htonl(INADDR_ANY); servAddr.sin_port = htons(LOCAL_SERVER_PORT); - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &y, sizeof(int)); - if (bind(s, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) { + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt_val, sizeof(opt_val)); + if (bind(sock, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) { perror("could not bind on port " LOCAL_SERVER_PORT_STR); return EXIT_FAILURE; } @@ -42,9 +42,9 @@ int main(int argc, char **argv) { memset(buffer, 0, BUFFER_SIZE); len = sizeof(cliAddr); - n = recvfrom(s, buffer, BUFFER_SIZE, 0, + num = recvfrom(sock, buffer, BUFFER_SIZE, 0, (struct sockaddr *) &cliAddr, &len); - if (n < 0) { + if (num < 0) { perror("could not receive data"); continue; } @@ -68,7 +68,7 @@ int main(int argc, char **argv) { } /* close socket */ - close(s); + close(sock); return EXIT_SUCCESS; } |