Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

UDP Sockets

UDP sockets. More...

Data Structures

struct  udp_socket
 UDP socket information structure. More...

struct  udp_socket
 UDP socket information structure. More...


Typedefs

typedef struct udp_socket UDPSOCKET
 UDP socket type.


Functions

UDPSOCKETNutUdpCreateSocket (u_short port)
 Create an UDP socket. More...

int NutUdpSendTo (UDPSOCKET *sock, u_long addr, u_short port, void *data, u_short len)
 Send an UDP datagram. More...

int NutUdpReceiveFrom (UDPSOCKET *sock, u_long *addr, u_short *port, void *data, u_short size, u_long timeout)
 Read received data UDP socket. Receive an UDP datagram. More...

int NutUdpDestroySocket (UDPSOCKET *sock)
 Close UDP socket. More...

UDPSOCKETNutUdpFindSocket (u_short port)
 Find a matching socket. More...


Variables

UDPSOCKETudpSocketList

Detailed Description

UDP sockets.

Nut/Net supports connectionless UDP sockets only.


Function Documentation

UDPSOCKET* NutUdpCreateSocket ( u_short port )
 

Create an UDP socket.

Parameters:
port   Server applications provide the local port number with this parameter. Client applications should pass zero.

Returns:
Socket descriptor of the newly created UDP socket or 0 if there is not enough memory left.

int NutUdpDestroySocket ( UDPSOCKET * sock )
 

Close UDP socket.

The memory occupied by the socket is immediately released after calling this function. The application must not use the socket after this call.

Parameters:
sock   Socket descriptor. This pointer must have been retrieved by calling NutUdpCreateSocket().

Returns:
0 on success, -1 otherwise.

UDPSOCKET* NutUdpFindSocket ( u_short port )
 

Find a matching socket.

Loop through all sockets and find a matching one.

Note:
Applications typically do not need to call this function.
Parameters:
port   Local port number.

Returns:
Socket descriptor.

int NutUdpReceiveFrom ( UDPSOCKET * sock,
u_long * addr,
u_short * port,
void * data,
u_short size,
u_long timeout )
 

Read received data UDP socket. Receive an UDP datagram.

Parameters:
sock   Socket descriptor. This pointer must have been retrieved by calling NutUdpCreateSocket().
Return values:
addr   IP address of the remote host in network byte order.
port   Remote port number in host byte order.
Parameters:
data   Pointer to the buffer that receives the data.
len   Number of bytes to be sent.

Returns:
The number of bytes received, if successful. The return value -1 indicates an error.

int NutUdpSendTo ( UDPSOCKET * sock,
u_long addr,
u_short port,
void * data,
u_short len )
 

Send an UDP datagram.

Parameters:
sock   Socket descriptor. This pointer must have been retrieved by calling NutUdpCreateSocket().
addr   IP address of the remote host in network byte order.
port   Remote port number in host byte order.
data   Pointer to a buffer containing the data to send.
len   Number of bytes to be sent.

Returns:
The number of bytes sent, if successful. The return value -1 indicates an error.


Variable Documentation

UDPSOCKET * udpSocketList
 

Linked list of all UDP sockets.


© 2000-2001 by egnite Software GmbH - visit http://www.ethernut.de/