|
NetCpp
v0.2
|
Class for platform-dependent code. More...
#include <posix_socket.hpp>

Public Member Functions | |
| PosixSocket (const protocol &prot) | |
| Constructor. | |
| virtual | ~PosixSocket () |
| Destructor. | |
| virtual void | connect (const Address &addr) |
| Method to connect() the socket to an address. | |
| virtual void | bind (const Address &addr) |
| Method to bind() the socket to an address. | |
| virtual int | read (void *buffer, size_t size) |
| Low-level read. | |
| virtual int | write (const void *buffer, size_t size) |
| Low-level write. | |
| virtual bool | close () |
| Method to close the socket. | |
| virtual void | accept (AbstractSystemSocket *sock) |
| Method to accept() a connection on the socket. | |
| virtual void | listen (int maxPendingConnections) |
| Listen operation. | |
Public Member Functions inherited from AbstractSystemSocket | |
| protocol | getProtocol () const |
| Method to get the socket protocol. | |
Private Attributes | |
| int | fd_ |
| Number of the file descriptor. | |
Additional Inherited Members | |
Protected Member Functions inherited from AbstractSystemSocket | |
| AbstractSystemSocket (const protocol &prot) | |
| Constructor. | |
Protected Attributes inherited from AbstractSystemSocket | |
| protocol | protocol_ |
| Protocol used by the socket. | |
Class for platform-dependent code.
This is the class containing the code for Posix platforms.
Definition at line 45 of file posix_socket.hpp.
| PosixSocket | ( | const protocol & | prot | ) |
Constructor.
The concrete class constructed depends on the specific protocol.
| prot | protocol used by the socket |
| runtime_error | in case of unknown protocol |
Definition at line 54 of file posix_socket.cpp.
|
virtual |
Destructor.
It just calls close()
Definition at line 80 of file posix_socket.cpp.

|
virtual |
Method to accept() a connection on the socket.
This method calls accept(). This method is usually invoked on the server-side for stream communications.
| sock | Socket on which the new connection must be accepted. |
| runtime_error | in case of error in accept() |
Implements AbstractSystemSocket.
Definition at line 130 of file posix_socket.cpp.

|
virtual |
Method to bind() the socket to an address.
This method calls bind(). This method is usually invoked on the server-side.
| addr | Address which the socket must be bound to |
| runtime_error | in case of error in bind() |
Implements AbstractSystemSocket.
Definition at line 174 of file posix_socket.cpp.

|
virtual |
Method to close the socket.
Implements AbstractSystemSocket.
Definition at line 118 of file posix_socket.cpp.

|
virtual |
Method to connect() the socket to an address.
This method calls connect(). This method is usually invoked on the client-side.
| addr | Address which the socket must be connected to |
| runtime_error | in case of error in connect() |
Implements AbstractSystemSocket.
Definition at line 213 of file posix_socket.cpp.

|
virtual |
Listen operation.
This method calls listen() and allows to specify the number of maximum allowed pending connections. This method is usually invoked on the server-side.
| max_pending_connections | Number of maximum allowed pending connections. |
| runtime_error | in case of error in listen() |
Implements AbstractSystemSocket.
Definition at line 153 of file posix_socket.cpp.

|
virtual |
Low-level read.
| buffer | Pointer to the buffer where read bytes must be stored |
| size | Number of bytes to be read |
Implements AbstractSystemSocket.
Definition at line 93 of file posix_socket.cpp.
|
virtual |
Low-level write.
| buffer | Pointer to the buffer containing bytes to be written |
| size | Number of bytes to be written |
Implements AbstractSystemSocket.
Definition at line 107 of file posix_socket.cpp.
|
private |
Number of the file descriptor.
This is the return value of open(), socket() or accept().
Definition at line 65 of file posix_socket.hpp.