diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-12-28 10:40:32 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-12-28 16:08:55 +0200 |
commit | c279f32d5ffc41ab41a1441687dcb9daea5e6475 (patch) | |
tree | 3af09feff14c81ea11cf88219d1116a98bf25258 /doc/examples | |
parent | 725cf45965e66b8d5a19fa39b679d0a2c505ce0f (diff) | |
download | gnutls-c279f32d5ffc41ab41a1441687dcb9daea5e6475.tar.gz |
updated and included in the documentation the udp code.
Diffstat (limited to 'doc/examples')
-rw-r--r-- | doc/examples/udp.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/doc/examples/udp.c b/doc/examples/udp.c index 3eb567af50..0c48ac1b5b 100644 --- a/doc/examples/udp.c +++ b/doc/examples/udp.c @@ -13,9 +13,7 @@ #include <netinet/in.h> #include <unistd.h> -#define SA struct sockaddr - -/* tcp.c */ +/* udp.c */ int udp_connect (void); void udp_close (int sd); @@ -27,7 +25,7 @@ udp_connect (void) { const char *PORT = "5557"; const char *SERVER = "127.0.0.1"; - int err, sd; + int err, sd, optval; struct sockaddr_in sa; /* connects to server @@ -39,7 +37,17 @@ udp_connect (void) sa.sin_port = htons (atoi (PORT)); inet_pton (AF_INET, SERVER, &sa.sin_addr); - err = connect (sd, (SA *) & sa, sizeof (sa)); +#if defined(IP_DONTFRAG) + optval = 1; + setsockopt (sd, IPPROTO_IP, IP_DONTFRAG, + (const void *) &optval, sizeof (optval)); +#elif defined(IP_MTU_DISCOVER) + optval = IP_PMTUDISC_DO; + setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, + (const void*) &optval, sizeof (optval)); +#endif + + err = connect (sd, (struct sockaddr *) & sa, sizeof (sa)); if (err < 0) { fprintf (stderr, "Connect error\n"); |