NetBurner 3.5.0
PDF Version
 
UDP Socket

The NetBurner UDP protocol Socket API. More...

Functions

int CreateRxUdpSocket (uint16_t listening_port)
 Open a UDP socket for receiving incoming UDP packets.
 
int CreateTxUdpSocket (const IPADDR &send_to_addr, uint16_t remote_port, uint16_t local_port)
 Open a UDP socket for transmitting UDP packets.
 
int CreateRxTxUdpSocket (const IPADDR &send_to_addr, uint16_t send_to_remote_port, uint16_t local_port)
 Open a UDP socket that can transmit and receive UDP packets.
 
int sendto (int sock, puint8_t what_to_send, int len_to_send, const IPADDR &to_addr, uint16_t remote_port)
 Send a UDP packet.
 
int sendtovia (int sock, puint8_t what_to_send, int len_to_send, const IPADDR &to_addr, uint16_t remote_port, int intfnum)
 Send a UDP packet on the specified interface.
 
int recvfrom (int sock, puint8_t buffer, int len, IPADDR *pAddr, uint16_t *pLocal_port, uint16_t *pRemote_port)
 Receive a UDP packet.
 
int SendFragmentedUdpPacket (const IPADDR &to, uint16_t source_port, uint16_t dest_port, puint8_t data, int length)
 Send a large fragmented UDP packet.
 
int CreateRxUdpSocketVia (uint16_t listening_port, int interfacenum)
 Open a UDP socket for receiving incoming UDP packets on the specified network interface, by interface number.
 
int CreateRxUdpSocketVia (uint16_t listening_port, const IPADDR interfaceIp)
 Open a UDP socket for receiving incoming UDP packets on the network interface with the specified IP address. If more than one interface has the same IP address, the lower interface number is used.
 
int CreateRxTxUdpSocketVia (const IPADDR send_to_addr, uint16_t send_to_remote_port, uint16_t local_port, int interfacenum)
 Open a UDP socket that can transmit and receive UDP packets on the local network interface specified by an interface number.
 
int CreateRxTxUdpSocketVia (const IPADDR send_to_addr, uint16_t send_to_remote_port, uint16_t local_port, IPADDR interfaceIp)
 Open a UDP socket that can transmit and receive UDP packets on the local network interface specified by an IP address.
 
int CreateTxUdpSocketVia (const IPADDR send_to_addr, uint16_t remote_port, uint16_t local_port, int interfacenum)
 Open a UDP socket for transmitting UDP packets on the local network interface specified by the interface number.
 
int CreateTxUdpSocketVia (const IPADDR send_to_addr, uint16_t remote_port, uint16_t local_port, IPADDR interfaceIp)
 Open a UDP socket for transmitting UDP packets on the local network interface specified by the interface IP address.
 

Detailed Description

The NetBurner UDP protocol Socket API.

#include< udp.h >

  1. As a C++ class, which makes memory management easier UDPPacket.
  2. Wrapper functions that implement a standard UDP sockets interface.For example, sendto() and recvfrom().

Function Documentation

◆ CreateRxTxUdpSocket()

int CreateRxTxUdpSocket ( const IPADDR & send_to_addr,
uint16_t send_to_remote_port,
uint16_t local_port )
inline

#include <udp.h>

Open a UDP socket that can transmit and receive UDP packets.

Parameters
send_to_addrDestination IP address
send_to_remote_portDestination port number
local_portLocal port number. A value of 0 will select a random port number (recommended)
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocket(), CreateTxUdpSocket()

◆ CreateRxTxUdpSocketVia() [1/2]

int CreateRxTxUdpSocketVia ( const IPADDR send_to_addr,
uint16_t send_to_remote_port,
uint16_t local_port,
int interfacenum )
inline

#include <udp.h>

Open a UDP socket that can transmit and receive UDP packets on the local network interface specified by an interface number.

Parameters
send_to_addrDestination IP address
send_to_remote_portDestination port number
local_portLocal port number. A value of 0 will select a random port number (recommended)
interfacenumLocal network interface number
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocketVia(), CreateTxUdpSocketVia()

◆ CreateRxTxUdpSocketVia() [2/2]

int CreateRxTxUdpSocketVia ( const IPADDR send_to_addr,
uint16_t send_to_remote_port,
uint16_t local_port,
IPADDR interfaceIp )
inline

#include <udp.h>

Open a UDP socket that can transmit and receive UDP packets on the local network interface specified by an IP address.

Parameters
send_to_addrDestination IP address
send_to_remote_portDestination port number
local_portLocal port number. A value of 0 will select a random port number (recommended)
interfaceIpIP address of local network interface to use
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocketVia(), CreateTxUdpSocketVia()

◆ CreateRxUdpSocket()

int CreateRxUdpSocket ( uint16_t listening_port)

#include <udp.h>

Open a UDP socket for receiving incoming UDP packets.

Returns a file descriptor that can be used by read functions such as: read() and select() to process multiple file descriptors at one time.

Parameters
listening_portPort to listen on for incoming packets
Returns
The file descriptor for the UDP socket
See also
CreateTxUdpSocket(), CreateRxTxUdpSocket()

◆ CreateRxUdpSocketVia() [1/2]

int CreateRxUdpSocketVia ( uint16_t listening_port,
const IPADDR interfaceIp )

#include <udp.h>

Open a UDP socket for receiving incoming UDP packets on the network interface with the specified IP address. If more than one interface has the same IP address, the lower interface number is used.

Returns a file descriptor that can be used by read functions such as read() and select().

Parameters
listening_portPort to listen on for incoming packets
interfaceIpIP address of the network interface
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocketVia(), CreateTxUdpSocketVia()

◆ CreateRxUdpSocketVia() [2/2]

int CreateRxUdpSocketVia ( uint16_t listening_port,
int interfacenum )

#include <udp.h>

Open a UDP socket for receiving incoming UDP packets on the specified network interface, by interface number.

Returns a file descriptor that can be used by read functions such as read() and select().

Parameters
listening_portPort to listen on for incoming packets
interfacenumNetwork interface number
Returns
The file descriptor for the UDP socket
See also
CreateTxUdpSocketVia(), CreateRxTxUdpSocketVia()

◆ CreateTxUdpSocket()

int CreateTxUdpSocket ( const IPADDR & send_to_addr,
uint16_t remote_port,
uint16_t local_port )
inline

#include <udp.h>

Open a UDP socket for transmitting UDP packets.

Returns a file descriptor that can be used by transmit functions such as sendto().

Parameters
send_to_addrDestination IP address
remote_portDestination port number
local_portLocal port number. A value of 0 will select a random port number (recommended)
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocket(), CreateRxTxUdpSocket()

◆ CreateTxUdpSocketVia() [1/2]

int CreateTxUdpSocketVia ( const IPADDR send_to_addr,
uint16_t remote_port,
uint16_t local_port,
int interfacenum )
inline

#include <udp.h>

Open a UDP socket for transmitting UDP packets on the local network interface specified by the interface number.

Returns a file descriptor that can be used by transmit functions such as sendto().

Parameters
send_to_addrDestination IP address
remote_portDestination port number
local_portLocal port number. A value of 0 will select a random port number (recommended)
interfacenumLocal network interface number
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocketVia(), CreateRxTxUdpSocketVia()

◆ CreateTxUdpSocketVia() [2/2]

int CreateTxUdpSocketVia ( const IPADDR send_to_addr,
uint16_t remote_port,
uint16_t local_port,
IPADDR interfaceIp )
inline

#include <udp.h>

Open a UDP socket for transmitting UDP packets on the local network interface specified by the interface IP address.

Returns a file descriptor that can be used by transmit functions such as sendto().

Parameters
send_to_addrDestination IP address
remote_portDestination port number
local_portLocal port number. A value of 0 will select a random port number (recommended)
interfaceIpIP address of the local network interface
Returns
The file descriptor for the UDP socket
See also
CreateRxUdpSocketVia(), CreateRxTxUdpSocketVia()

◆ recvfrom()

int recvfrom ( int sock,
puint8_t buffer,
int len,
IPADDR * pAddr,
uint16_t * pLocal_port,
uint16_t * pRemote_port )
inline

#include <udp.h>

Receive a UDP packet.

Parameters
sockFile descriptor from a previous call to CreateRxUdpSocket() or CreateRxTxSocket()
bufferPointer to BYTE array buffer to store received UDP packet data
lenMaximum number of bytes to receive
pAddrPointer to an IPADDR variable to store the sender's IP address of the packet
pLocal_portPointer to WORD variable to store the local port number of the packet
pRemote_portPointer to WORD variable to store the sender's port number of the packet
Returns
The number of bytes received, or a negative number if an error occurred UDP Error Codes
See also
sendto(), sendtovia()

◆ SendFragmentedUdpPacket()

int SendFragmentedUdpPacket ( const IPADDR & to,
uint16_t source_port,
uint16_t dest_port,
puint8_t data,
int length )
inline

#include <udp.h>

Send a large fragmented UDP packet.

Parameters
toDestination IP address
source_portSource port number, a value of 0 selects a random source port number (recommended)
dest_portDestination port number
dataPointer to data to send
lengthNumber of bytes to send
Returns
The number of bytes sent, or 0 if an error occurred.

◆ sendto()

int sendto ( int sock,
puint8_t what_to_send,
int len_to_send,
const IPADDR & to_addr,
uint16_t remote_port )
inline

#include <udp.h>

Send a UDP packet.

Parameters
sockSocket to send packet to
what_to_sendPointer to data to be sent
len_to_sendNumber of data bytes to send
to_addrDestination IP address
remote_portDestination port number
Returns
The number of bytes sent, or a negative number if an error occurred UDP Error Codes
See also
sendtovia(), recvfrom()

◆ sendtovia()

int sendtovia ( int sock,
puint8_t what_to_send,
int len_to_send,
const IPADDR & to_addr,
uint16_t remote_port,
int intfnum )
inline

#include <udp.h>

Send a UDP packet on the specified interface.

Parameters
sockSocket to send packet to
what_to_sendPointer to data to be sent
len_to_sendNumber of data bytes to send
to_addrDestination IP address
remote_portDestination port number
intfnumInterface number
Returns
The number of bytes sent, or a negative number if an error occurred UDP Error Codes
See also
sendto(), recvfrom()