Ocean
|
This class is the base class for all sockets. More...
Public Types | |
enum | SocketResult { SR_SUCCEEDED = 0 , SR_FAILED , SR_BUSY , SR_NOT_CONNECTED } |
Definition of individual result values. More... | |
typedef SOCKET | SocketId |
Definition of a socket id. More... | |
typedef int | SocketId |
Definition of a socket id. More... | |
typedef std::vector< uint8_t > | Buffer |
Definition of a vector holding 8 bit values. More... | |
Public Member Functions | |
virtual | ~Socket () |
Destructs a socket object. More... | |
SocketId | id () const |
Returns the socket id. More... | |
Address4 | address () const |
Returns the own address of this socket. More... | |
Port | port () const |
Returns the own port of this socket. More... | |
virtual bool | setAddress (const Address4 &address) |
Sets the own address of this socket. More... | |
virtual bool | setPort (const Port &port) |
Sets the own port of this socket. More... | |
operator bool () const | |
Returns whether this socket is valid. More... | |
Static Public Member Functions | |
static constexpr SocketId | invalidSocketId () |
Returns an invalid socket id. More... | |
static bool | setBlockingMode (const SocketId socketId, const bool blocking) |
Sets the blocking mode of a socket. More... | |
Protected Member Functions | |
Socket () | |
Creates a new socket object. More... | |
Socket (const Socket &object)=delete | |
Disabled copy constructor. More... | |
bool | setBlockingMode (const bool blocking) |
Sets the blocking mode of this socket. More... | |
size_t | maximalMessageSize (const size_t defaultSize=65536) |
Returns the maximal message size in bytes. More... | |
bool | releaseSocket () |
Releases the socket. More... | |
virtual bool | onScheduler () |
The scheduler event function. More... | |
Socket & | operator= (const Socket &object)=delete |
Disabled copy operator. More... | |
Protected Attributes | |
SocketId | socketId_ = invalidSocketId() |
Socket id. More... | |
Lock | lock_ |
Socket lock. More... | |
NetworkResource | networkResource_ |
The network resource object. More... | |
Friends | |
class | SocketScheduler |
class | Resolver |
This class is the base class for all sockets.
typedef std::vector<uint8_t> Ocean::Network::Socket::Buffer |
Definition of a vector holding 8 bit values.
typedef SOCKET Ocean::Network::Socket::SocketId |
Definition of a socket id.
typedef int Ocean::Network::Socket::SocketId |
Definition of a socket id.
Definition of individual result values.
|
virtual |
Destructs a socket object.
|
protected |
Creates a new socket object.
|
protecteddelete |
Disabled copy constructor.
object | The object which would be copied |
Address4 Ocean::Network::Socket::address | ( | ) | const |
Returns the own address of this socket.
If the systems supports more than one network address use this function to determine which address is used for this socket.
|
inline |
Returns the socket id.
|
staticconstexpr |
Returns an invalid socket id.
|
protected |
Returns the maximal message size in bytes.
Beware: Connection oriented socket have no message restrictions, in those cases the specified default value will be returned.
defaultSize | Default message size for connection oriented sockets |
|
protectedvirtual |
The scheduler event function.
Reimplemented in Ocean::Network::PackagedConnectionlessServer, Ocean::Network::ConnectionOrientedServer, Ocean::Network::ConnectionOrientedClient, and Ocean::Network::ConnectionlessServer.
|
inlineexplicit |
Returns whether this socket is valid.
Disabled copy operator.
object | The object which would be copied |
Port Ocean::Network::Socket::port | ( | ) | const |
Returns the own port of this socket.
|
protected |
Releases the socket.
|
virtual |
Sets the own address of this socket.
If the systems supports more than one network address use this function to define which address to use for this socket.
However, usually is not necessary to define the local address.
address | The address to use for this socket |
|
protected |
Sets the blocking mode of this socket.
blocking | True, if the socket will block |
|
static |
Sets the blocking mode of a socket.
socketId | The id of the socket for which the mode will be set, must be valid |
blocking | True, if the socket will block |
|
virtual |
Sets the own port of this socket.
port | Own port to set |
Reimplemented in Ocean::Network::PackagedUDPServer.
|
friend |
|
friend |
|
protected |
The network resource object.
|
protected |
Socket id.