* Client with Resume capability example::
* Simple client example with SRP authentication::
* Simple client example in C++::
-* Helper function for TCP connections::
+* Helper functions for TCP connections::
+* Helper functions for UDP connections::
@end menu
@node Simple client example with anonymous authentication
@verbatiminclude examples/ex-cxx.cpp
-@node Helper function for TCP connections
-@subsection Helper function for TCP connections
+@node Helper functions for TCP connections
+@subsection Helper functions for TCP connections
-This helper function abstracts away TCP connection handling from the
+Those helper function abstract away TCP connection handling from the
other examples. It is required to build some examples.
@verbatiminclude examples/tcp.c
+@node Helper functions for UDP connections
+@subsection Helper functions for UDP connections
+
+The UDP helper functions abstract away UDP connection handling from the
+other examples. It is required to build the examples using UDP.
+
+@verbatiminclude examples/udp.c
+
@node Server examples
@section Server examples
#include <netinet/in.h>
#include <unistd.h>
-#define SA struct sockaddr
-
-/* tcp.c */
+/* udp.c */
int udp_connect (void);
void udp_close (int sd);
{
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
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");