<< Previous | Index | Next >>

udp_peek


int udp_peek( udp_Socket *s, _udp_datagram_info *udi );

Description

Look into the UDP socket receive buffer to see if there is a datagram ready to be read using udp_recvfrom(). This function does not remove the datagram from the buffer, but it allows the application to determine the full details about the next datagram, including whether the datagram was broadcast.

The returned data is put in *udi. udi must point to a valid data structure, or be NULL. The data structure is:


typedef struct {
longword remip; //
Remote host IP address
word remport; // Remote host port number
int len; // Length of datagram
byte flags; // Bit mask (defined below)
byte iface; // Interface number
} _udp_datagram_info;

The flags field may have one of the following values:


UDI_ICMP_ERROR   - This is an ICMP error entry.
UDI_TOS_MASK     - Type-of-service bit mask.
UDI_BROADCAST_LL - Received on broadcast link layer address.
UDI_BROADCAST_IP - Received on broadcast network (IP) address.

Parameters

s

UDP socket to check

udi

Where to store the returned information.

Return Value

 1: A normal datagram is in the receive buffer.
 0: No datagram waiting.
-3: ICMP error message in receive buffer - will only be returned if udi is not NULL.

Library

UDP.LIB

See Also

udp_recvfrom


TCP/IP Manual
Vol 1
<<Previous | Index | Next>> rabbit.com