148#if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
149# error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
152#ifndef PLIBSYS_HEADER_PSOCKET_H
153#define PLIBSYS_HEADER_PSOCKET_H
struct PError_ PError
Opaque data structure for an error object.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.
#define P_LIB_API
Exports a symbol from a shared library.
P_LIB_API pboolean p_socket_close(PSocket *socket, PError **error)
Closes a socket.
P_LIB_API pboolean p_socket_check_connect_result(PSocket *socket, PError **error)
Checks a connection state after calling p_socket_connect().
P_LIB_API pssize p_socket_receive_from(const PSocket *socket, PSocketAddress **address, pchar *buffer, psize buflen, PError **error)
Receives data from a given socket and saves a remote address.
P_LIB_API PSocketType p_socket_get_type(const PSocket *socket)
Gets a socket type.
P_LIB_API PSocket * p_socket_accept(const PSocket *socket, PError **error)
Accepts a socket incoming connection.
P_LIB_API PSocketAddress * p_socket_get_remote_address(const PSocket *socket, PError **error)
Gets a socket remote endpoint address.
enum PSocketDirection_ PSocketDirection
Socket direction for data operations.
P_LIB_API PSocket * p_socket_new(PSocketFamily family, PSocketType type, PSocketProtocol protocol, PError **error)
Creates a new PSocket object.
P_LIB_API pssize p_socket_receive(const PSocket *socket, pchar *buffer, psize buflen, PError **error)
Receives data from a given socket.
enum PSocketIOCondition_ PSocketIOCondition
Socket IO waiting (polling) conditions.
P_LIB_API void p_socket_set_blocking(PSocket *socket, pboolean blocking)
Sets a socket blocking mode.
enum PSocketType_ PSocketType
Socket types.
P_LIB_API void p_socket_set_timeout(PSocket *socket, pint timeout)
Sets a socket timeout value for blocking I/O operations.
P_LIB_API pboolean p_socket_listen(PSocket *socket, PError **error)
Puts a socket into a listening state.
P_LIB_API pint p_socket_get_timeout(const PSocket *socket)
Gets a socket timeout for blocking I/O operations.
P_LIB_API pint p_socket_get_fd(const PSocket *socket)
Gets an underlying file descriptor of a socket.
P_LIB_API pboolean p_socket_shutdown(PSocket *socket, pboolean shutdown_read, pboolean shutdown_write, PError **error)
Shutdowns a full-duplex socket data transfer link.
P_LIB_API pint p_socket_get_listen_backlog(const PSocket *socket)
Gets a socket listen backlog parameter.
P_LIB_API void p_socket_free(PSocket *socket)
Closes a socket (if not closed yet) and frees its resources.
P_LIB_API pboolean p_socket_set_buffer_size(const PSocket *socket, PSocketDirection dir, psize size, PError **error)
Sets the socket buffer size for a given data transfer direction.
P_LIB_API PSocket * p_socket_new_from_fd(pint fd, PError **error)
Creates a new PSocket object from a file descriptor.
enum PSocketProtocol_ PSocketProtocol
Socket protocols specified by the IANA.
P_LIB_API PSocketAddress * p_socket_get_local_address(const PSocket *socket, PError **error)
Gets a socket local (bound) address.
P_LIB_API pboolean p_socket_io_condition_wait(const PSocket *socket, PSocketIOCondition condition, PError **error)
Waits for a specified I/O condition on socket.
P_LIB_API pboolean p_socket_is_closed(const PSocket *socket)
Checks whether a socket is closed.
P_LIB_API PSocketProtocol p_socket_get_protocol(const PSocket *socket)
Gets a socket data transfer protocol.
P_LIB_API pboolean p_socket_connect(PSocket *socket, PSocketAddress *address, PError **error)
Connects a socket to a given remote address.
struct PSocket_ PSocket
Socket opaque structure.
PSocketProtocol_
Socket protocols specified by the IANA.
@ P_SOCKET_PROTOCOL_DEFAULT
Default protocol.
@ P_SOCKET_PROTOCOL_SCTP
SCTP protocol.
@ P_SOCKET_PROTOCOL_UNKNOWN
Unknown protocol.
@ P_SOCKET_PROTOCOL_UDP
UDP protocol.
@ P_SOCKET_PROTOCOL_TCP
TCP protocol.
P_LIB_API pboolean p_socket_is_connected(const PSocket *socket)
Checks whether a socket is connected.
P_LIB_API pssize p_socket_send_to(const PSocket *socket, PSocketAddress *address, const pchar *buffer, psize buflen, PError **error)
Sends data through a given socket to a given address.
PSocketType_
Socket types.
@ P_SOCKET_TYPE_UNKNOWN
Unknown type.
@ P_SOCKET_TYPE_SEQPACKET
Connection-less, reliable, datagram passing (i.e.
@ P_SOCKET_TYPE_STREAM
Connection oritented, reliable, stream of bytes (i.e.
@ P_SOCKET_TYPE_DATAGRAM
Connection-less, unreliable, datagram passing (i.e.
P_LIB_API void p_socket_set_keepalive(PSocket *socket, pboolean keepalive)
Sets the socket SO_KEEPALIVE flag.
P_LIB_API pboolean p_socket_get_blocking(PSocket *socket)
Checks whether socket is used in a blocking mode.
P_LIB_API pboolean p_socket_bind(const PSocket *socket, PSocketAddress *address, pboolean allow_reuse, PError **error)
Binds a socket to a given local address.
P_LIB_API PSocketFamily p_socket_get_family(const PSocket *socket)
Gets a socket address family.
P_LIB_API pboolean p_socket_get_keepalive(const PSocket *socket)
Checks whether the SO_KEEPALIVE flag is enabled.
P_LIB_API pssize p_socket_send(const PSocket *socket, const pchar *buffer, psize buflen, PError **error)
Sends data through a given socket.
PSocketIOCondition_
Socket IO waiting (polling) conditions.
@ P_SOCKET_IO_CONDITION_POLLOUT
Ready to write.
@ P_SOCKET_IO_CONDITION_POLLIN
Ready to read.
P_LIB_API void p_socket_set_listen_backlog(PSocket *socket, pint backlog)
Sets a socket listen backlog parameter.
PSocketDirection_
Socket direction for data operations.
@ P_SOCKET_DIRECTION_SND
Send direction.
@ P_SOCKET_DIRECTION_RCV
Receive direction.
enum PSocketFamily_ PSocketFamily
Socket address family.
struct PSocketAddress_ PSocketAddress
Socket address opaque structure.
signed int pssize
Type for a platform independent signed size_t.
char pchar
Type for a char.
unsigned int psize
Type for a platform independent size_t.
signed int pboolean
Type for a bool.