UDP Sockets
[Socket API]

Application interface for UDP sockets. More...

Collaboration diagram for UDP Sockets:

Application interface for UDP sockets.

UDP server and client applications typically use this order of API calls

Assigning a stream to a UDP socket is not supported. Applications must use NutUdpSendTo() and NutUdpReceiveFrom().

For historical reasons, Nut/Net buffers only the last incoming UDP datagram for a specific port by default. Any previously received datagram will be discarded, if it hasn't been passed to the application in the meantime. Most applications will run fine with this. But it will fail for example, if more than one response is expected on a previously broadcasted request. This problem can be solved by calling NutUdpSetSockOpt() to specify a receive buffer size.

 #include <sys/socket.h>

 ...

 UDPSOCKET *sock;
 u_short udp_bufsiz = 1024;

 ...

 sock = NutUdpCreateSocket(20191);
 NutUdpSetSockOpt(sock, SO_RCVBUF, &udp_bufsiz, sizeof(udp_bufsiz));

Nut/Net supports connectionless UDP sockets only. A Berkley like bind call is not available.

Todo:
There is no similar call like NutTcpError() available for UDP.

© 2000-2010 by contributors - visit http://www.ethernut.de/