|
@@ -43,7 +43,8 @@ int net_sock(int type, int port) {
|
|
|
int reuseaddr = 1;
|
|
|
struct sockaddr_in addr;
|
|
|
|
|
|
- if ((fd = socket(AF_INET, (type == 1 ? SOCK_STREAM : SOCK_DGRAM), 0)) == -1) {
|
|
|
+ if ((fd = socket(AF_INET, (type == 1 ? SOCK_STREAM : SOCK_DGRAM), 0))
|
|
|
+ == -1) {
|
|
|
perror("Unable to create net socket");
|
|
|
return -1;
|
|
|
}
|
|
@@ -54,8 +55,8 @@ int net_sock(int type, int port) {
|
|
|
addr.sin_port = htons(port);
|
|
|
|
|
|
if (type == 1) {
|
|
|
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr))
|
|
|
- == -1) {
|
|
|
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
|
|
|
+ sizeof(reuseaddr)) == -1) {
|
|
|
perror("Unable to set socket options");
|
|
|
return -1;
|
|
|
}
|
|
@@ -114,9 +115,9 @@ int main(int argc, char *argv[]) {
|
|
|
exit(EXIT_FAILURE);
|
|
|
}
|
|
|
|
|
|
- if (strncmp(argv[1], TCP) == 0) {
|
|
|
+ if (strncmp(argv[1], TCP, 3) == 0) {
|
|
|
type = 1;
|
|
|
- } else if (strncmp(argv[1], UDP) == 0) {
|
|
|
+ } else if (strncmp(argv[1], UDP, 3) == 0) {
|
|
|
type = 0;
|
|
|
} else {
|
|
|
exit(EXIT_FAILURE);
|