/** @file udp.h * @date April 20, 2009 */ #ifndef UDP_H_ #define UDP_H_ /** Receives a datagram from the socket. * * @param buffer The buffer. * @param size The size of the buffer. * @param actual The number of bytes stored. * @param peer The peer address. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_recv( void * buffer, size_t size, size_t * actual, peer_t * peer); /** Resolves an address and stores information into a peer structure. * * @param name The name to resolve. * @param port The port number as text. * @param peer The peer address. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_resolve( const char * name, const char * port, peer_t * peer); /** Sends a datagram through the socket. * * @param peer The peer address. * @param buffer The buffer. * @param port The port number as text. * @param size The size of the buffer in bytes. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_send( const peer_t * peer, const void * buffer, size_t size); /** Starts UDP without binding to a port. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_start_client(void); /** Starts UDP and binds to a port. * * @param port The port number. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_start_server(u_short port); /** * Stops UDP and closes the socket. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_stop(void); /** * Waits for an incoming message or a timeout. * * @param ms The timeout in milliseconds. * @param timeout Set to 1 if there is a timeout; 0 otherwise. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ extern int udp_wait(size_t ms, int * timeout); #endif /* UDP_H_ */