#include <Socket.h++>


Public Member Functions | |
| virtual | ~Socket () throw () |
| Destructor. | |
| virtual void | init () throw (SocketException) |
| Initialize the socket. | |
| virtual void | connect (const String &addr, uint16_t port) throw (IOException) |
| Connect the socket to a remote endpoint. | |
| virtual void | connect (const SocketAddress &addr) throw (IOException) |
| Connect the socket to a remote endpoint. | |
| virtual void | shutdown () throw () |
| Shut down the socket. | |
| void | setTimeout (int msec) throw (SocketException) |
| Set the timeout for the socket. | |
| void | setReceiveBufSize (size_t size) throw (SocketException) |
| Set the size of the socket's internal receive buffer. | |
| size_t | getReceiveBufSize () const throw (SocketException) |
| Get the size of the socket's internal receive buffer. | |
| void | setSendBufSize (size_t size) throw (SocketException) |
| Set the size of the socket's internal send buffer. | |
| size_t | getSendBufSize () const throw (SocketException) |
| Get the size of the socket's internal send buffer. | |
| void | setLingerTime (int msec) throw (SocketException) |
| Set the linger time for the socket. | |
| int | getLingerTime () const throw (SocketException) |
| Get the linger time for the socket. | |
| void | setReuseAddress (bool enable) throw (SocketException) |
| Enable or disable the SO_REUSEADDR option on the socket. | |
| bool | getReuseAddress () const throw (SocketException) |
| Determine if the SO_REUSEADDR option is enabled or disabled. | |
| void | setKeepAlive (bool enable) throw (SocketException) |
| Enable or disable the SO_KEEPALIVE option on the socket. | |
| bool | getKeepAlive () throw (SocketException) |
| Determine if the SO_KEEPALIVE option is enabled or disabled. | |
| void | setTCPDelay (bool enable) throw (SocketException) |
| Enable or disable the Nagle algorithm for send coalescing. | |
| bool | getTCPDelay () throw (SocketException) |
| Determine if the Nagle algorithm is enabled or disabled. | |
| bool | isInitialized () const throw () |
| Determine if the socket has been initialized. | |
| bool | isConnected () const throw () |
| Determine if the socket is connected. | |
| NetProtocol | getType () const throw () |
| Get the socket type. | |
| const SocketAddress & | getLocalAddress () const throw () |
| Get the address of the local end of the socket. | |
| const SocketAddress & | getRemoteAddress () const throw () |
| Get the address of the remote (peer) end of the socket. | |
Protected Types | |
| enum | IOWaitMode { WaitWrite, WaitRead } |
Protected Member Functions | |
| Socket (NetProtocol type=ProtoTCP) throw () | |
| Construct a new Socket of the specified type. | |
| SocketHandle | getSocketHandle () const throw () |
| Get the underlying socket handle for this socket. | |
| void | waitForIO (IOWaitMode mode) throw (IOException) |
| Wait for the socket to become ready for reading or writing. | |
Protected Attributes | |
| NetProtocol | _type |
| The socket type. | |
| SocketHandle | _socket |
| A handle to the socket itself. | |
| SocketAddress | _raddr |
| The remote address. | |
| SocketAddress | _laddr |
| The local address. | |
| int | _sotimeout |
| The timeout value. | |
| bool | _connected |
| bool | _reuseAddr |
Friends | |
| class | ServerSocket |
| class | SocketMuxer |
enum IOWaitMode [protected] |
| Socket | ( | NetProtocol | type = ProtoTCP |
) | throw () [protected] |
| ~Socket | ( | ) | throw () [virtual] |
Destructor.
Closes and destroys the socket.
| void connect | ( | const SocketAddress & | addr | ) | throw (IOException) [virtual] |
Connect the socket to a remote endpoint.
| addr | The address. |
| IOException | If an error occurs. |
Reimplemented in DatagramSocket, and StreamSocket.
| void connect | ( | const String & | addr, | |
| uint16_t | port | |||
| ) | throw (IOException) [virtual] |
Connect the socket to a remote endpoint.
| addr | The address, which may either be a dot-separated IP address or a DNS name. | |
| port | The port number. |
| IOException | If an error occurs. |
Reimplemented in DatagramSocket, and StreamSocket.
| bool getKeepAlive | ( | ) | throw (SocketException) |
Determine if the SO_KEEPALIVE option is enabled or disabled.
| SocketException | If a socket error occurs. |
| int getLingerTime | ( | ) | const throw (SocketException) |
Get the linger time for the socket.
| SocketException | If the linger time could not be retrieved. |
| const SocketAddress& getLocalAddress | ( | ) | const throw () [inline] |
Get the address of the local end of the socket.
| size_t getReceiveBufSize | ( | ) | const throw (SocketException) |
Get the size of the socket's internal receive buffer.
| SocketException | If the size could not be changed. |
| const SocketAddress& getRemoteAddress | ( | ) | const throw () [inline] |
Get the address of the remote (peer) end of the socket.
| bool getReuseAddress | ( | ) | const throw (SocketException) |
Determine if the SO_REUSEADDR option is enabled or disabled.
| SocketException | If a socket error occurs. |
| size_t getSendBufSize | ( | ) | const throw (SocketException) |
Get the size of the socket's internal send buffer.
| SocketException | If the size could not be changed. |
| SocketHandle getSocketHandle | ( | ) | const throw () [inline, protected] |
Get the underlying socket handle for this socket.
| bool getTCPDelay | ( | ) | throw (SocketException) |
Determine if the Nagle algorithm is enabled or disabled.
| SocketException | If a socket error occurs. |
| NetProtocol getType | ( | ) | const throw () [inline] |
Get the socket type.
| void init | ( | ) | throw (SocketException) [virtual] |
Initialize the socket.
This method creates the underlying socket object.
| SocketException | If the socket could not be created. |
Reimplemented in ServerSocket.
| bool isConnected | ( | ) | const throw () [inline] |
Determine if the socket is connected.
| bool isInitialized | ( | ) | const throw () [inline] |
Determine if the socket has been initialized.
| void setKeepAlive | ( | bool | enable | ) | throw (SocketException) |
Enable or disable the SO_KEEPALIVE option on the socket.
| enable | true to enable the option false to disable it. |
| SocketException | If a socket error occurs. |
| void setLingerTime | ( | int | msec | ) | throw (SocketException) |
Set the linger time for the socket.
| msec | The new linger time, in milliseconds; a negative value disables the linger feature. |
| SocketException | If the linger time could not be changed. |
| void setReceiveBufSize | ( | size_t | size | ) | throw (SocketException) |
Set the size of the socket's internal receive buffer.
| size | The new size, in bytes. |
| SocketException | If the size could not be changed. |
| void setReuseAddress | ( | bool | enable | ) | throw (SocketException) |
Enable or disable the SO_REUSEADDR option on the socket.
This method may only be called before the socket has been initialized. This option is off by default in newly created sockets.
| enable | true to enable the option false to disable it. |
| SocketException | If a socket error occurs, or if the call was made after the socket was initialized. |
| void setSendBufSize | ( | size_t | size | ) | throw (SocketException) |
Set the size of the socket's internal send buffer.
| size | The new size, in bytes. |
| SocketException | If the size could not be changed. |
| void setTCPDelay | ( | bool | enable | ) | throw (SocketException) |
Enable or disable the Nagle algorithm for send coalescing.
| enable | true to enable the Nagle algorithm (TCP_NODELAY off), false to disable it (TCP_NODELAY on). |
| SocketException | If a socket error occurs. |
| void setTimeout | ( | int | msec | ) | throw (SocketException) |
Set the timeout for the socket.
The timeout affects both I/O and connections.
| msec | The timeout, in milliseconds. |
| SocketException | If an error occurs. |
Reimplemented in StreamSocket.
| void shutdown | ( | ) | throw () [virtual] |
Shut down the socket.
Closes the connection and destroys the underlying socket object.
Reimplemented in ServerSocket, and StreamSocket.
| void waitForIO | ( | IOWaitMode | mode | ) | throw (IOException) [protected] |
Wait for the socket to become ready for reading or writing.
| mode | The wait mode; one of WaitWrite or WaitRead. |
| IOException | On timeout or other error. |
friend class ServerSocket [friend] |
Reimplemented in StreamSocket.
friend class SocketMuxer [friend] |
bool _connected [protected] |
SocketAddress _laddr [protected] |
The local address.
SocketAddress _raddr [protected] |
The remote address.
bool _reuseAddr [protected] |
SocketHandle _socket [protected] |
A handle to the socket itself.
int _sotimeout [protected] |
The timeout value.
NetProtocol _type [protected] |
The socket type.
1.5.9