BioInt
1.02.00
BioInt: An integrative biological object-oriented application framework and interpreter
|
#include <BioSocketBase.h>
Public Types | |
enum | format { pf_unspec = PF_UNSPEC, pf_unix = PF_UNIX, pf_inet = PF_INET, pf_max = PF_MAX } |
Address format specifications, for the create() member. More... | |
enum | type { sock_stream = SOCK_STREAM, sock_dgram = SOCK_DGRAM, sock_raw = SOCK_RAW, sock_rdm = SOCK_RDM, sock_seqpacket = SOCK_SEQPACKET } |
Type specification for the create() method. More... | |
enum | protocol { proto_ip = IPPROTO_IP, proto_icmp = IPPROTO_ICMP, proto_tcp = IPPROTO_TCP, proto_pup = IPPROTO_PUP, proto_udp = IPPROTO_UDP, proto_idp = IPPROTO_IDP, proto_raw = IPPROTO_RAW, proto_max = IPPROTO_MAX } |
Protocol to be used on this socket. More... | |
enum | { invalid_socket = INVALID_SOCKET } |
enum | msgflag { msg_none = 0, msg_oob = MSG_OOB, msg_peek = MSG_PEEK, msg_dontroute = MSG_DONTROUTE } |
Flags to use with recv/send methods. More... | |
enum | shuthow { shut_recv = 0, shut_send = 1, shut_both = 2 } |
Flags for the shutdown() method. More... | |
enum | errors { socket_error = SOCKET_ERROR, eintr = WSAEINTR, ebadf = WSAEBADF, eacces = WSAEACCES, efault = WSAEFAULT, einval = WSAEINVAL, emfile = WSAEMFILE, ewouldblock = WSAEWOULDBLOCK, einprogress = WSAEINPROGRESS, ealready = WSAEALREADY, enotsock = WSAENOTSOCK, edestaddrreq = WSAEDESTADDRREQ, emsgsize = WSAEMSGSIZE, eprototype = WSAEPROTOTYPE, enoprotoopt = WSAENOPROTOOPT, eprotonosupport = WSAEPROTONOSUPPORT, esocktnotsupport = WSAESOCKTNOSUPPORT, eopnotsupp = WSAEOPNOTSUPP, epfnosupport = WSAEPFNOSUPPORT, afnosupport = WSAEAFNOSUPPORT, eaddrinuse = WSAEADDRINUSE, eaddrnotavail = WSAEADDRNOTAVAIL, enetdown = WSAENETDOWN, enetunreach = WSAENETUNREACH, enetreset = WSAENETRESET, econnaborted = WSAECONNABORTED, econnreset = WSAECONNRESET, enobufs = WSAENOBUFS, eisconn = WSAEISCONN, enotconn = WSAENOTCONN, eshutdown = WSAESHUTDOWN, etoomanyrefs = WSAETOOMANYREFS, etimedout = WSAETIMEDOUT, econnrefused = WSAECONNREFUSED, eloop = WSAELOOP, enametoolong = WSAENAMETOOLONG, ehostdown = WSAEHOSTDOWN, ehostunreach = WSAEHOSTUNREACH, host_not_found = WSAHOST_NOT_FOUND, try_again = WSATRY_AGAIN, no_recovery = WSANO_RECOVERY, no_data = WSANO_DATA } |
Errors that may be set by the different socklibpp::sock operations. More... | |
enum | ioctl_cmd { fionbio = FIONBIO, fionread = FIONREAD, siocatmark = SIOCATMARK } |
Flags to use in the sock::ioctl method. More... | |
enum | mode { passive, active } |
Flags to use in the convenience constructor. More... | |
enum | optlevel { sol_socket = SOL_SOCKET, ipproto_tcp = IPPROTO_TCP } |
Levels of socket options for the getsockopt/setsockopt methods. More... | |
enum | optname { so_acceptconn = SO_ACCEPTCONN, so_broadcast = SO_BROADCAST, so_debug = SO_DEBUG, so_dontroute = SO_DONTROUTE, so_error = SO_ERROR, so_keepalive = SO_KEEPALIVE, so_linger = SO_LINGER, so_oobinline = SO_OOBINLINE, so_rcvbuf = SO_RCVBUF, so_reuseaddr = SO_REUSEADDR, so_sndbuf = SO_SNDBUF, so_type = SO_TYPE, tcp_nodelay = TCP_NODELAY } |
Option names for the getsockopt/setsockopt methods. More... | |
enum | selectstate { readable = 1, writable = 2, exceptable = 4 } |
select() results More... | |
Public Member Functions | |
BioSocket () throw () | |
Default constructor. | |
BioSocket (socket_type fd_) throw () | |
Constructor that uses an already created socket descriptor. | |
BioSocket (format, type, protocol=proto_ip) throw () | |
Constructs and allocates a new socket. | |
BioSocket | accept () throw () |
Accept incomming connections in a listening socket. | |
BioSocket | accept (BioSocketAddress &) throw () |
Accepts incomming connections in a listening socket and stores the accepted address. | |
bool | bind (const BioSocketAddress &) throw () |
Bind the socket to a specific address. | |
bool | close () throw () |
Close the socket, releasing the resources used by it. | |
bool | connect (const BioSocketAddress &) throw () |
Create a connection to the specified address. | |
bool | peername (BioSocketAddress &) const throw () |
Get the address of the peer at which the socket is connected. | |
bool | sockname (BioSocketAddress &) throw () |
Get the local address of the socket. | |
bool | getsockopt (optlevel, optname, int &) const throw () |
Retrieve a socket option. | |
bool | getsockopt (optlevel, optname, bool &) const throw () |
Retrieve a socket option. | |
bool | ioctl (ioctl_cmd, unsigned long &) throw () |
Control the mode of a socket. | |
bool | listen (int=3) throw () |
Put the socket in passive (listen) mode for incomming connections. | |
int | recv (char *, int, msgflag=msg_none) throw () |
Receive data from a socket. | |
int | recvfrom (BioSocketAddress &, char *, int, msgflag=msg_none) throw () |
Receive a datagram and store the source address. | |
bool | can_read (long=0, long=0) const throw () |
Check if the socket has data to be read. | |
bool | wait_read (long &, long &) const throw () |
Wait until data can be read. | |
bool | wait_read () const throw () |
Wait until data can be read. | |
bool | can_write (int=0, int=0) throw () |
Check if the socket can be written to. | |
bool | can_except (int=0, int=0) throw () |
Checks for the presence of out-of-band data or if any exceptional error conditions. | |
unsigned | select (int=0, int=0) throw () |
Do a normal select(), returning the state of the socket. | |
int | send (const char *, int, msgflag=msg_none) throw () |
Send data on a connected socket. | |
int | sendto (const BioSocketAddress &, const char *, int, msgflag=msg_none) throw () |
Send data to a specific destination. | |
bool | setsockopt (optlevel, optname, int) throw () |
Set a socket option. | |
bool | shutdown (shuthow) throw () |
Disable sends and/or receives on a socket. | |
bool | create (format, type, protocol=proto_ip) throw () |
Create a new socket. | |
bool | socket (format fmt, type tp, protocol pr=proto_ip) throw () |
Synonym for create() | |
bool | sendall (const char *, int, msgflag=msg_none) throw () |
Send all data. | |
bool | recvall (char *, int, msgflag=msg_none) throw () |
Recv all data. | |
bool | block (bool) throw () |
Set the blocking mode. | |
bool | reuseaddr () const throw () |
Query if it can reuse the addr. | |
bool | reuseaddr (bool) throw () |
Set the reuse addr option. | |
int | sendbuf () const throw () |
Get the size of the internal send buffer. | |
void | sendbuf (int) throw () |
Set the size of the internal send buffer. | |
int | recvbuf () const throw () |
Get the size of the internal recv buffer. | |
void | recvbuf (int) throw () |
Set the size of the internal recv buffer. | |
Public Attributes | |
socket_type | fd |
The descriptor of this socket. | |
int | error |
The error code of the last operation performed. |
enum BioSocket::errors |
Errors that may be set by the different socklibpp::sock operations.
enum BioSocket::format |
Address format specifications, for the create() member.
enum BioSocket::ioctl_cmd |
enum BioSocket::mode |
enum BioSocket::msgflag |
enum BioSocket::optlevel |
enum BioSocket::optname |
Option names for the getsockopt/setsockopt methods.
so_acceptconn |
(bool) Socket is listen()ing. |
so_broadcast |
(bool) Socket is configured for the transmission of broadcast messages. |
so_debug |
(bool) Debugging is enabled. |
so_dontroute |
(bool) Routing is disabled. |
so_error |
(int) Retrieve error status and clear. |
so_keepalive |
(bool Keepalives are being sent. |
so_linger |
(struct linger *) Returns the current linger options. |
so_oobinline |
(bool) Out-of-band data is being received in the normal data stream. |
so_rcvbuf |
(int) Buffer size for receives |
so_reuseaddr |
(bool) The socket may be bound to an address which is already in use. |
so_sndbuf |
(int) Buffer size for sends |
so_type |
(int) The type of the socket (e.g. sock_stream). |
tcp_nodelay |
(bool) Disables the Nagle algorithm for send coalescing. |
enum BioSocket::protocol |
select() results
enum BioSocket::shuthow |
Flags for the shutdown() method.
enum BioSocket::type |
Type specification for the create() method.
BioSocket::BioSocket | ( | ) | throw () [inline] |
BioSocket::BioSocket | ( | socket_type | fd_ | ) | throw () [inline] |
Constructor that uses an already created socket descriptor.
_fd | a socket_type descriptor. |
BioSocket::BioSocket | ( | format | , |
type | , | ||
protocol | = proto_ip |
||
) | throw () |
Constructs and allocates a new socket.
BioSocket BioSocket::accept | ( | ) | throw () |
Accept incomming connections in a listening socket.
BioSocket BioSocket::accept | ( | BioSocketAddress & | ) | throw () |
Accepts incomming connections in a listening socket and stores the accepted address.
bool BioSocket::bind | ( | const BioSocketAddress & | ) | throw () |
Bind the socket to a specific address.
bool BioSocket::block | ( | bool | ) | throw () |
Set the blocking mode.
bool BioSocket::can_except | ( | int | = 0 , |
int | = 0 |
||
) | throw () |
Checks for the presence of out-of-band data or if any exceptional error conditions.
bool BioSocket::can_read | ( | long | = 0 , |
long | = 0 |
||
) | const throw () |
Check if the socket has data to be read.
bool BioSocket::can_write | ( | int | = 0 , |
int | = 0 |
||
) | throw () |
Check if the socket can be written to.
bool BioSocket::close | ( | ) | throw () |
Close the socket, releasing the resources used by it.
bool BioSocket::connect | ( | const BioSocketAddress & | ) | throw () |
Create a connection to the specified address.
bool BioSocket::create | ( | format | , |
type | , | ||
protocol | = proto_ip |
||
) | throw () |
Create a new socket.
bool BioSocket::getsockopt | ( | optlevel | , |
optname | , | ||
int & | |||
) | const throw () |
Retrieve a socket option.
bool BioSocket::getsockopt | ( | optlevel | , |
optname | , | ||
bool & | |||
) | const throw () |
Retrieve a socket option.
bool BioSocket::ioctl | ( | ioctl_cmd | , |
unsigned long & | |||
) | throw () |
Control the mode of a socket.
bool BioSocket::listen | ( | int | = 3 | ) | throw () |
Put the socket in passive (listen) mode for incomming connections.
bool BioSocket::peername | ( | BioSocketAddress & | ) | const throw () |
Get the address of the peer at which the socket is connected.
int BioSocket::recv | ( | char * | , |
int | , | ||
msgflag | = msg_none |
||
) | throw () |
Receive data from a socket.
bool BioSocket::recvall | ( | char * | , |
int | , | ||
msgflag | = msg_none |
||
) | throw () |
Recv all data.
int BioSocket::recvbuf | ( | ) | const throw () |
Get the size of the internal recv buffer.
void BioSocket::recvbuf | ( | int | ) | throw () |
Set the size of the internal recv buffer.
int BioSocket::recvfrom | ( | BioSocketAddress & | , |
char * | , | ||
int | , | ||
msgflag | = msg_none |
||
) | throw () |
Receive a datagram and store the source address.
bool BioSocket::reuseaddr | ( | ) | const throw () |
Query if it can reuse the addr.
bool BioSocket::reuseaddr | ( | bool | ) | throw () |
Set the reuse addr option.
unsigned BioSocket::select | ( | int | = 0 , |
int | = 0 |
||
) | throw () |
Do a normal select(), returning the state of the socket.
int BioSocket::send | ( | const char * | , |
int | , | ||
msgflag | = msg_none |
||
) | throw () |
Send data on a connected socket.
bool BioSocket::sendall | ( | const char * | , |
int | , | ||
msgflag | = msg_none |
||
) | throw () |
Send all data.
int BioSocket::sendbuf | ( | ) | const throw () |
Get the size of the internal send buffer.
void BioSocket::sendbuf | ( | int | ) | throw () |
Set the size of the internal send buffer.
int BioSocket::sendto | ( | const BioSocketAddress & | , |
const char * | , | ||
int | , | ||
msgflag | = msg_none |
||
) | throw () |
Send data to a specific destination.
bool BioSocket::setsockopt | ( | optlevel | , |
optname | , | ||
int | |||
) | throw () |
Set a socket option.
bool BioSocket::shutdown | ( | shuthow | ) | throw () |
Disable sends and/or receives on a socket.
bool BioSocket::socket | ( | format | fmt, |
type | tp, | ||
protocol | pr = proto_ip |
||
) | throw () [inline] |
bool BioSocket::sockname | ( | BioSocketAddress & | ) | throw () |
Get the local address of the socket.
bool BioSocket::wait_read | ( | long & | , |
long & | |||
) | const throw () |
Wait until data can be read.
bool BioSocket::wait_read | ( | ) | const throw () |
Wait until data can be read.
int BioSocket::error [mutable] |
The error code of the last operation performed.
If no error ocurred in the last operation, the value is zero.
The descriptor of this socket.
This usually have the size of an int, but may be signed or unsigned depending on the platform. You should never use < or > to compare it with any other value. The only useful value to compare is socklibpp::sock::invalid_socket, and you should always test using == or !=.