File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,6 @@ main(int argc, char **argv)
38
38
errx (1 , "usage: %s <0|1> <port_number>" , argv [0 ]);
39
39
40
40
reuse = atoi (argv [1 ]);
41
- if (reuse > 0 )
42
- printf ("Setting SO_REUSEADDR flag...\n" );
43
41
44
42
sa .sin_family = AF_INET ;
45
43
sa .sin_port = htons (atoi (argv [2 ]));
@@ -48,9 +46,12 @@ main(int argc, char **argv)
48
46
if ((fd = socket (AF_INET , SOCK_STREAM , 0 )) == -1 )
49
47
err (1 , "socket" );
50
48
51
- if (reuse && (setsockopt (fd , SOL_SOCKET , SO_REUSEADDR ,
52
- & optval , sizeof (optval )) == -1 ))
53
- err (1 , "setsockopt" );
49
+ if (reuse ) {
50
+ printf ("Setting SO_REUSEADDR flag...\n" );
51
+ if (setsockopt (fd , SOL_SOCKET , SO_REUSEADDR ,
52
+ & optval , sizeof (optval )) == -1 )
53
+ err (1 , "setsockopt" );
54
+ }
54
55
55
56
if (bind (fd , (struct sockaddr * ) & sa , sizeof (sa )) == -1 )
56
57
err (1 , "bind" );
You can’t perform that action at this time.
0 commit comments