Lely core libraries  2.3.4
sock.h
Go to the documentation of this file.
1 
22 #ifndef LELY_IO_SOCK_H_
23 #define LELY_IO_SOCK_H_
24 
25 #include <lely/io/io.h>
26 
27 enum {
36 };
37 
38 enum {
49 };
50 
51 enum {
53  IO_MSG_PEEK = 1 << 0,
55  IO_MSG_OOB = 1 << 1,
60  IO_MSG_WAITALL = 1 << 2
61 };
62 
63 enum {
70 };
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
87 io_handle_t io_open_socket(int domain, int type);
88 
102 int io_open_socketpair(int domain, int type, io_handle_t handle_vector[2]);
103 
118 ssize_t io_recv(io_handle_t handle, void *buf, size_t nbytes, io_addr_t *addr,
119  int flags);
120 
134 ssize_t io_send(io_handle_t handle, const void *buf, size_t nbytes,
135  const io_addr_t *addr, int flags);
136 
150 
160 int io_connect(io_handle_t handle, const io_addr_t *addr);
161 
172 int io_sock_get_domain(io_handle_t handle);
173 
183 int io_sock_get_type(io_handle_t handle);
184 
191 int io_sock_bind(io_handle_t handle, const io_addr_t *addr);
192 
207 int io_sock_listen(io_handle_t handle, int backlog);
208 
219 int io_sock_shutdown(io_handle_t handle, int how);
220 
228 int io_sock_get_sockname(io_handle_t handle, io_addr_t *addr);
229 
237 int io_sock_get_peername(io_handle_t handle, io_addr_t *addr);
238 
245 int io_sock_get_maxconn(void);
246 
258 
269 
280 int io_sock_set_broadcast(io_handle_t handle, int broadcast);
281 
291 int io_sock_get_debug(io_handle_t handle);
292 
303 int io_sock_set_debug(io_handle_t handle, int debug);
304 
315 
326 int io_sock_set_dontroute(io_handle_t handle, int dontroute);
327 
335 int io_sock_get_error(io_handle_t handle, int *perror);
336 
347 
370  io_handle_t handle, int keepalive, int time, int interval);
371 
381 int io_sock_get_linger(io_handle_t handle);
382 
393 int io_sock_set_linger(io_handle_t handle, int time);
394 
406 
418 int io_sock_set_oobinline(io_handle_t handle, int oobinline);
419 
429 int io_sock_get_rcvbuf(io_handle_t handle);
430 
440 int io_sock_set_rcvbuf(io_handle_t handle, int size);
441 
449 int io_sock_set_rcvtimeo(io_handle_t handle, int timeout);
450 
461 
472 int io_sock_set_reuseaddr(io_handle_t handle, int reuseaddr);
473 
483 int io_sock_get_sndbuf(io_handle_t handle);
484 
494 int io_sock_set_sndbuf(io_handle_t handle, int size);
495 
503 int io_sock_set_sndtimeo(io_handle_t handle, int timeout);
504 
515 
526 int io_sock_set_tcp_nodelay(io_handle_t handle, int nodelay);
527 
534 ssize_t io_sock_get_nread(io_handle_t handle);
535 
547 
559 int io_sock_set_mcast_loop(io_handle_t handle, int loop);
560 
572 
583 int io_sock_set_mcast_ttl(io_handle_t handle, int ttl);
584 
599  io_handle_t handle, unsigned int index, const io_addr_t *group);
600 
615 int io_sock_mcast_block_source(io_handle_t handle, unsigned int index,
616  const io_addr_t *group, const io_addr_t *source);
617 
632 int io_sock_mcast_unblock_source(io_handle_t handle, unsigned int index,
633  const io_addr_t *group, const io_addr_t *source);
634 
649  io_handle_t handle, unsigned int index, const io_addr_t *group);
650 
666 int io_sock_mcast_join_source_group(io_handle_t handle, unsigned int index,
667  const io_addr_t *group, const io_addr_t *source);
668 
684 int io_sock_mcast_leave_source_group(io_handle_t handle, unsigned int index,
685  const io_addr_t *group, const io_addr_t *source);
686 
687 #ifdef __cplusplus
688 }
689 #endif
690 
691 #endif // !LELY_IO_SOCK_H_
io_sock_mcast_block_source
int io_sock_mcast_block_source(io_handle_t handle, unsigned int index, const io_addr_t *group, const io_addr_t *source)
Blocks data from a given source to a given multicast group.
Definition: sock.c:1230
io_sock_mcast_leave_group
int io_sock_mcast_leave_group(io_handle_t handle, unsigned int index, const io_addr_t *group)
Leaves an any-source multicast group.
Definition: sock.c:1294
io_sock_set_mcast_ttl
int io_sock_set_mcast_ttl(io_handle_t handle, int ttl)
Sets the TTL (time to live) value for IP multicast traffic on a socket (the default is 1).
Definition: sock.c:1165
io_accept
io_handle_t io_accept(io_handle_t handle, io_addr_t *addr)
Accepts an incoming connection on a listening socket.
Definition: sock.c:341
io_sock_get_debug
int io_sock_get_debug(io_handle_t handle)
Checks if debugging is enabled for a socket.
Definition: sock.c:597
io_sock_set_tcp_nodelay
int io_sock_set_tcp_nodelay(io_handle_t handle, int nodelay)
Disables Nagle's algorithm for send coalescing if nodelay is non-zero, and enables it otherwise.
Definition: sock.c:1000
io_sock_get_type
int io_sock_get_type(io_handle_t handle)
Obtains the type of a network socket (the second parameter in a call to io_open_socket() or io_open_s...
Definition: sock.c:393
io_sock_set_reuseaddr
int io_sock_set_reuseaddr(io_handle_t handle, int reuseaddr)
Enables a socket to be bound to an address that is already in use if reuseaddr is non-zero,...
Definition: sock.c:909
IO_SOCK_UNIX
@ IO_SOCK_UNIX
A UNIX domain socket (only supported on POSIX platforms).
Definition: sock.h:35
io_sock_get_tcp_nodelay
int io_sock_get_tcp_nodelay(io_handle_t handle)
Checks if Nagle's algorithm for send coalescing is enabled for a socket.
Definition: sock.c:979
io_sock_get_sndbuf
int io_sock_get_sndbuf(io_handle_t handle)
Obtains the size (in bytes) of the send buffer of a socket.
Definition: sock.c:928
io_sock_get_acceptconn
int io_sock_get_acceptconn(io_handle_t handle)
Checks if a socket is currently listening for incoming connections.
Definition: sock.c:536
io_sock_set_rcvbuf
int io_sock_set_rcvbuf(io_handle_t handle, int size)
Sets the size (in bytes) of the receive buffer of a socket.
Definition: sock.c:854
IO_SHUT_WR
@ IO_SHUT_WR
Disables further send operations.
Definition: sock.h:67
__io_addr
An opaque network address type.
Definition: addr.h:30
io_sock_get_nread
ssize_t io_sock_get_nread(io_handle_t handle)
Obtains the amount of data (in bytes) in the input buffer of a socket.
Definition: sock.c:1020
io_sock_mcast_leave_source_group
int io_sock_mcast_leave_source_group(io_handle_t handle, unsigned int index, const io_addr_t *group, const io_addr_t *source)
Leaves a source-specific multicast group.
Definition: sock.c:1356
io_open_socketpair
int io_open_socketpair(int domain, int type, io_handle_t handle_vector[2])
Opens a pair of connected sockets.
Definition: sock.c:185
io_handle
An I/O device handle.
Definition: handle.h:33
io_sock_set_dontroute
int io_sock_set_dontroute(io_handle_t handle, int dontroute)
Bypasses normal routing for a socket if dontroute is non-zero, and disables this option otherwise (di...
Definition: sock.c:658
io_sock_get_peername
int io_sock_get_peername(io_handle_t handle, io_addr_t *addr)
Obtains the peer address of a socket and stores the result in *addr.
Definition: sock.c:500
io_sock_get_mcast_loop
int io_sock_get_mcast_loop(io_handle_t handle)
Checks if the loopback of outgoing multicast datagrams is enabled for a socket.
Definition: sock.c:1050
io_sock_set_debug
int io_sock_set_debug(io_handle_t handle, int debug)
Enables (platform dependent) debugging output for a socket if debug is non-zero, and disables this op...
Definition: sock.c:618
IO_SOCK_BTH
@ IO_SOCK_BTH
A Bluetooth socket.
Definition: sock.h:29
io_sock_set_oobinline
int io_sock_set_oobinline(io_handle_t handle, int oobinline)
Requests that out-of-band data is placed into the normal data stream of socket if oobinline is non-ze...
Definition: sock.c:818
io.h
io_sock_get_linger
int io_sock_get_linger(io_handle_t handle)
Obtains the linger time (in seconds) of a socket.
Definition: sock.c:760
io_sock_set_broadcast
int io_sock_set_broadcast(io_handle_t handle, int broadcast)
Enables a socket to send broadcast messages if broadcast is non-zero, and disables this option otherw...
Definition: sock.c:578
io_sock_set_sndbuf
int io_sock_set_sndbuf(io_handle_t handle, int size)
Sets the size (in bytes) of the send buffer of a socket.
Definition: sock.c:945
IO_SHUT_RDWR
@ IO_SHUT_RDWR
Disables further send and receive operations.
Definition: sock.h:69
io_sock_set_sndtimeo
int io_sock_set_sndtimeo(io_handle_t handle, int timeout)
Sets the timeout (in milliseconds) of a send operation on a socket.
Definition: sock.c:959
io_sock_get_reuseaddr
int io_sock_get_reuseaddr(io_handle_t handle)
Checks if a socket is allowed to be bound to an address that is already in use.
Definition: sock.c:888
io_sock_get_dontroute
int io_sock_get_dontroute(io_handle_t handle)
Checks if routing is disabled for a socket.
Definition: sock.c:637
io_open_socket
io_handle_t io_open_socket(int domain, int type)
Opens a network socket.
Definition: sock.c:78
io_sock_set_mcast_loop
int io_sock_set_mcast_loop(io_handle_t handle, int loop)
Enables the loopback of outgoing multicast datagrams for a socket if loop is non-zero,...
Definition: sock.c:1090
io_sock_mcast_unblock_source
int io_sock_mcast_unblock_source(io_handle_t handle, unsigned int index, const io_addr_t *group, const io_addr_t *source)
Unblocks data from a given source to a given multicast group.
Definition: sock.c:1262
io_sock_set_keepalive
int io_sock_set_keepalive(io_handle_t handle, int keepalive, int time, int interval)
Enables or disables the TCP keep-alive option for a socket (disabled by default).
Definition: sock.c:713
io_sock_set_linger
int io_sock_set_linger(io_handle_t handle, int time)
Sets the time (in seconds) io_close() will wait for unsent messages to be sent.
Definition: sock.c:777
io_sock_get_domain
int io_sock_get_domain(io_handle_t handle)
Obtains the domain of a socket (the first parameter in a call to io_open_socket() or io_open_socketpa...
Definition: sock.c:377
io_sock_get_oobinline
int io_sock_get_oobinline(io_handle_t handle)
Checks if out-of-band data is received in the normal data stream of a socket.
Definition: sock.c:797
io_sock_get_rcvbuf
int io_sock_get_rcvbuf(io_handle_t handle)
Obtains the size (in bytes) of the receive buffer of a socket.
Definition: sock.c:837
io_sock_get_broadcast
int io_sock_get_broadcast(io_handle_t handle)
Checks if a socket is allowed to send broadcast messages.
Definition: sock.c:557
io_connect
int io_connect(io_handle_t handle, const io_addr_t *addr)
Connects a socket to a network address.
Definition: sock.c:358
io_send
ssize_t io_send(io_handle_t handle, const void *buf, size_t nbytes, const io_addr_t *addr, int flags)
Performs a send operation on a network socket.
Definition: sock.c:323
IO_SHUT_RD
@ IO_SHUT_RD
Disables further receive operations.
Definition: sock.h:65
io_sock_bind
int io_sock_bind(io_handle_t handle, const io_addr_t *addr)
Binds a local network address to a socket.
Definition: sock.c:409
io_sock_get_keepalive
int io_sock_get_keepalive(io_handle_t handle)
Checks if the TCP keep-alive option is enabled for a socket.
Definition: sock.c:692
IO_MSG_WAITALL
@ IO_MSG_WAITALL
On stream-oriented sockets, block until the full amount of data can be returned.
Definition: sock.h:60
io_recv
ssize_t io_recv(io_handle_t handle, void *buf, size_t nbytes, io_addr_t *addr, int flags)
Performs a receive operation on a network socket.
Definition: sock.c:305
io_sock_mcast_join_source_group
int io_sock_mcast_join_source_group(io_handle_t handle, unsigned int index, const io_addr_t *group, const io_addr_t *source)
Joins a source-specific multicast group.
Definition: sock.c:1324
IO_SOCK_DGRAM
@ IO_SOCK_DGRAM
A datagram-oriented, typically connectionless-mode, socket type.
Definition: sock.h:48
io_sock_get_error
int io_sock_get_error(io_handle_t handle, int *perror)
Obtains and clears the current error number of a socket, and stores the value in *perror.
Definition: sock.c:677
IO_MSG_PEEK
@ IO_MSG_PEEK
Peeks at incoming data.
Definition: sock.h:53
io_sock_listen
int io_sock_listen(io_handle_t handle, int backlog)
Marks a connection-mode socket (IO_SOCK_STREAM) as accepting connections.
Definition: sock.c:423
IO_SOCK_IPV6
@ IO_SOCK_IPV6
An IPv6 socket.
Definition: sock.h:33
io_sock_get_maxconn
int io_sock_get_maxconn(void)
Returns the maximum queue length for pending connections.
Definition: sock.c:530
IO_SOCK_IPV4
@ IO_SOCK_IPV4
An IPv4 socket.
Definition: sock.h:31
io_sock_mcast_join_group
int io_sock_mcast_join_group(io_handle_t handle, unsigned int index, const io_addr_t *group)
Joins an any-source multicast group.
Definition: sock.c:1200
io_sock_get_sockname
int io_sock_get_sockname(io_handle_t handle, io_addr_t *addr)
Obtains the locally-bound name of a socket and stores the resulting address in *addr.
Definition: sock.c:470
IO_SOCK_STREAM
@ IO_SOCK_STREAM
A stream-oriented connection-mode socket type.
Definition: sock.h:43
io_sock_shutdown
int io_sock_shutdown(io_handle_t handle, int how)
Causes all or part of a full-duplex connection on a socket to be shut down.
Definition: sock.c:434
io_sock_set_rcvtimeo
int io_sock_set_rcvtimeo(io_handle_t handle, int timeout)
Sets the timeout (in milliseconds) of a receive operation on a socket.
Definition: sock.c:868
io_sock_get_mcast_ttl
int io_sock_get_mcast_ttl(io_handle_t handle)
Obtains the TTL (time to live) value for IP multicast traffic on a socket.
Definition: sock.c:1125
IO_MSG_OOB
@ IO_MSG_OOB
Requests out-of-band data.
Definition: sock.h:55