summaryrefslogtreecommitdiff
path: root/doc/examples/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'doc/examples/udp.c')
-rw-r--r--doc/examples/udp.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/doc/examples/udp.c b/doc/examples/udp.c
index 989ffcc6bf..beded4d0d1 100644
--- a/doc/examples/udp.c
+++ b/doc/examples/udp.c
@@ -1,7 +1,7 @@
/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
#include <stdio.h>
@@ -22,45 +22,45 @@ void udp_close(int sd);
*/
extern int udp_connect(void)
{
- const char *PORT = "5557";
- const char *SERVER = "127.0.0.1";
- int err, sd;
+ const char *PORT = "5557";
+ const char *SERVER = "127.0.0.1";
+ int err, sd;
#if defined(IP_DONTFRAG) || defined(IP_MTU_DISCOVER)
- int optval;
+ int optval;
#endif
- struct sockaddr_in sa;
+ struct sockaddr_in sa;
- /* connects to server
- */
- sd = socket(AF_INET, SOCK_DGRAM, 0);
+ /* connects to server
+ */
+ sd = socket(AF_INET, SOCK_DGRAM, 0);
- memset(&sa, '\0', sizeof(sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons(atoi(PORT));
- inet_pton(AF_INET, SERVER, &sa.sin_addr);
+ memset(&sa, '\0', sizeof(sa));
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(atoi(PORT));
+ inet_pton(AF_INET, SERVER, &sa.sin_addr);
#if defined(IP_DONTFRAG)
- optval = 1;
- setsockopt(sd, IPPROTO_IP, IP_DONTFRAG,
- (const void *) &optval, sizeof(optval));
+ 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));
+ 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");
- exit(1);
- }
+ err = connect(sd, (struct sockaddr *)&sa, sizeof(sa));
+ if (err < 0) {
+ fprintf(stderr, "Connect error\n");
+ exit(1);
+ }
- return sd;
+ return sd;
}
/* closes the given socket descriptor.
*/
extern void udp_close(int sd)
{
- close(sd);
+ close(sd);
}