Topic: Method sequence for UDP/DTLS

Hi,

I am trying to figure out how to make the echoserver/echoclient work with UPD and DTLS. I took the echoerver (tcpserv04.c) and replaced two lines of code with what I hoped would make it work with UDP and DTLS.  The lines I changed are as follows:

original line:
if( (ctx = wolfSSL_CTX_new(wolfTLSv1_server_method()) ) == NULL)

changed to:
if( (ctx = wolfSSL_CTX_new(wolfDTLSv1_server_method()) ) == NULL)

and

original line:
listenfd = Socket(AF_INET, SOCK_STREAM, 0);

changed to:
listenfd = Socket(AF_INET, SOCK_DGRAM, 0);

When I try to run the server, I get
Listen error: operation not supported

Is there a particular method I should be calling or not calling? Anyone who can give any help on this I would greatly appreciate it.

Doug

P.S. By the way, I did use --enable-dtls when I configured the wolfSSL embedded SSL library.

Share

Re: Method sequence for UDP/DTLS

The echoserver tutorial will listen() on the TCP socket. When you are using UDP, you don't listen() on the socket ever. Normally on UDP, you just recvfrom() on the socket and process the datagrams as they arrive. If you look at the wolfSSL echoserver, it has this implemented. (Note, the wolfSSL example echoserver is more complicated than the tutorial version.)