ObjFW
Classes | Typedefs | Functions
OFUDPSocket.h File Reference
#import "OFObject.h"
#import "OFKernelEventObserver.h"
#import "socket.h"

Go to the source code of this file.

Classes

struct  of_udp_socket_address_t
 A struct which represents a host / port pair for a UDP socket. More...
 
class  OFUDPSocket
 A class which provides functions to create and use UDP sockets. More...
 

Typedefs

typedef void(^ of_udp_socket_async_resolve_block_t) (OFString *host, uint16_t port, of_udp_socket_address_t address, OFException *OF_NULLABLE exception)
 A block which is called when the host / port pair for the UDP socket has been resolved. More...
 
typedef bool(^ of_udp_socket_async_receive_block_t) (OFUDPSocket *socket, void *buffer, size_t length, of_udp_socket_address_t sender, OFException *OF_NULLABLE exception)
 A block which is called when a packet has been received. More...
 

Functions

bool of_udp_socket_address_equal (of_udp_socket_address_t *address1, of_udp_socket_address_t *address2)
 Compares two of_udp_socket_address_t for equality. More...
 
uint32_t of_udp_socket_address_hash (of_udp_socket_address_t *address)
 Returns the hash for the specified of_udp_socket_address_t. More...
 

Typedef Documentation

typedef bool(^ of_udp_socket_async_receive_block_t) (OFUDPSocket *socket, void *buffer, size_t length, of_udp_socket_address_t sender, OFException *OF_NULLABLE exception)

A block which is called when a packet has been received.

Parameters
socketThe UDP which received a packet
bufferThe buffer the packet has been written to
lengthThe length of the packet
senderThe address of the sender of the packet
exceptionAn exception which occurred while receiving or nil on success
Returns
A bool whether the same block should be used for the next receive
typedef void(^ of_udp_socket_async_resolve_block_t) (OFString *host, uint16_t port, of_udp_socket_address_t address, OFException *OF_NULLABLE exception)

A block which is called when the host / port pair for the UDP socket has been resolved.

Parameters
hostThe host that has been resolved
portThe port of the host / port pair
addressThe address of the resolved host / port pair
exceptionAn exception which occurred while resolving or nil on success

Function Documentation

bool of_udp_socket_address_equal ( of_udp_socket_address_t address1,
of_udp_socket_address_t address2 
)

Compares two of_udp_socket_address_t for equality.

Parameters
address1The address to compare with the second address
address2The second address
Returns
Whether the two addresses are equal
uint32_t of_udp_socket_address_hash ( of_udp_socket_address_t address)

Returns the hash for the specified of_udp_socket_address_t.

Parameters
addressThe address to hash
Returns
The hash for the specified of_udp_socket_address_t