aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/socket-example.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/socket-example.c')
-rw-r--r--examples/socket-example.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/examples/socket-example.c b/examples/socket-example.c
index b372e8e..2aaa9cc 100644
--- a/examples/socket-example.c
+++ b/examples/socket-example.c
@@ -79,11 +79,11 @@
79# define PACKAGE_VERSION "unknown" 79# define PACKAGE_VERSION "unknown"
80#endif 80#endif
81 81
82#define MY_VERBOSE 0x0001 82#define MY_VERBOSE 0x0001U
83#define MY_QUIET 0x0002 83#define MY_QUIET 0x0002U
84#define MY_SERVER 0x0004 84#define MY_SERVER 0x0004U
85#define MY_TCP 0x0008 85#define MY_TCP 0x0008U
86#define MY_UDP 0x0000 86#define MY_UDP 0x0000U
87 87
88#define MY_TIMEOUT 30 // in seconds 88#define MY_TIMEOUT 30 // in seconds
89 89
@@ -95,7 +95,7 @@
95///////////////// 95/////////////////
96#pragma mark - Variables 96#pragma mark - Variables
97 97
98int should_exit = 0; 98static int should_exit = 0;
99 99
100 100
101////////////////// 101//////////////////
@@ -107,17 +107,17 @@ int should_exit = 0;
107 107
108int main( int argc, char * argv[] ); 108int main( int argc, char * argv[] );
109 109
110int my_client( int s, int opts, struct sockaddr_storage * sap ); 110int my_client( int s, unsigned opts, struct sockaddr_storage * sap );
111void my_connlog( int opts, const struct sockaddr_storage * sa, const char * fmt, ...); 111void my_connlog( unsigned opts, const struct sockaddr_storage * sa, const char * fmt, ...);
112int my_error( const char * fmt, ...); 112int my_error( const char * fmt, ...);
113char * my_ntop(const struct sockaddr_storage * sa, char * buff, size_t len); 113char * my_ntop(const struct sockaddr_storage * sa, char * buff, size_t len);
114void my_print( int opts, const char * fmt, ...); 114void my_print( unsigned opts, const char * fmt, ...);
115int my_server( int s, int opts ); 115int my_server( int s, unsigned opts );
116int my_server_tcp( int s, int opts ); 116int my_server_tcp( int s, unsigned opts );
117int my_server_udp( int s, int opts ); 117int my_server_udp( int s, unsigned opts );
118void my_signal( int sig ); 118void my_signal( int sig );
119void my_usage( void ); 119void my_usage( void );
120void my_verbose( int opts, const char * fmt, ...); 120void my_verbose( unsigned opts, const char * fmt, ...);
121 121
122 122
123///////////////// 123/////////////////
@@ -133,7 +133,7 @@ int main(int argc, char * argv[])
133 int opt_index; 133 int opt_index;
134 int rc; 134 int rc;
135 int s; 135 int s;
136 int opt; 136 unsigned opt;
137 unsigned opts; 137 unsigned opts;
138 const char * laddr; 138 const char * laddr;
139 const char * port; 139 const char * port;
@@ -311,7 +311,7 @@ int main(int argc, char * argv[])
311} 311}
312 312
313 313
314int my_client( int s, int opts, struct sockaddr_storage * sap ) 314int my_client( int s, unsigned opts, struct sockaddr_storage * sap )
315{ 315{
316 struct pollfd fds[2]; 316 struct pollfd fds[2];
317 int rc; 317 int rc;
@@ -417,7 +417,7 @@ int my_client( int s, int opts, struct sockaddr_storage * sap )
417} 417}
418 418
419 419
420void my_connlog( int opts, const struct sockaddr_storage * sa, const char * fmt, ...) 420void my_connlog( unsigned opts, const struct sockaddr_storage * sa, const char * fmt, ...)
421{ 421{
422 va_list args; 422 va_list args;
423 char host[INET6_ADDRSTRLEN+32]; 423 char host[INET6_ADDRSTRLEN+32];
@@ -466,7 +466,7 @@ char * my_ntop(const struct sockaddr_storage * sa, char * buff, size_t len)
466} 466}
467 467
468 468
469void my_print( int opts, const char * fmt, ...) 469void my_print( unsigned opts, const char * fmt, ...)
470{ 470{
471 va_list args; 471 va_list args;
472 if ((opts & MY_QUIET)) 472 if ((opts & MY_QUIET))
@@ -480,7 +480,7 @@ void my_print( int opts, const char * fmt, ...)
480} 480}
481 481
482 482
483int my_server( int s, int opts ) 483int my_server( int s, unsigned opts )
484{ 484{
485 struct sockaddr_storage sa; 485 struct sockaddr_storage sa;
486 socklen_t sa_len; 486 socklen_t sa_len;
@@ -498,7 +498,7 @@ int my_server( int s, int opts )
498} 498}
499 499
500 500
501int my_server_tcp( int s, int opts ) 501int my_server_tcp( int s, unsigned opts )
502{ 502{
503 struct pollfd fds[10]; 503 struct pollfd fds[10];
504 nfds_t nfds; 504 nfds_t nfds;
@@ -610,7 +610,7 @@ int my_server_tcp( int s, int opts )
610} 610}
611 611
612 612
613int my_server_udp( int s, int opts ) 613int my_server_udp( int s, unsigned opts )
614{ 614{
615 struct pollfd fds[1]; 615 struct pollfd fds[1];
616 int rc; 616 int rc;
@@ -693,7 +693,7 @@ void my_usage(void)
693 return; 693 return;
694} 694}
695 695
696void my_verbose( int opts, const char * fmt, ...) 696void my_verbose( unsigned opts, const char * fmt, ...)
697{ 697{
698 va_list args; 698 va_list args;
699 if (!(opts & MY_VERBOSE)) 699 if (!(opts & MY_VERBOSE))