#include <rex/platform/socket.h>
|
| | Socket (SocketHandle handle) |
|
| Socket (Socket &&other) noexcept |
|
Socket & | operator= (Socket &&other) noexcept |
|
bool | IsValid () const |
| SocketHandle | GetHandle () const |
| i32 | Connect (const sockaddr *name, i32 name_len) const |
| i32 | Bind (const sockaddr *name, i32 name_len) const |
| i32 | GetLocalName (sockaddr *name, i32 *name_len) const |
| i32 | Listen (i32 backlog) const |
| Socket | Accept (sockaddr *name, i32 *name_len) const |
| i32 | Shutdown (i32 how) const |
| i32 | Recv (void *buf, i32 len, i32 flags) const |
| i32 | RecvFrom (void *buf, i32 len, i32 flags, sockaddr *from, i32 *from_len) const |
| i32 | Send (const void *buf, i32 len, i32 flags) const |
| i32 | SendTo (const void *buf, i32 len, i32 flags, const sockaddr *to, i32 to_len) const |
| i32 | SetOption (i32 level, i32 name, const void *value, i32 len) const |
| i32 | GetOption (i32 level, i32 name, void *value, i32 *len) const |
| i32 | GetPeerName (sockaddr *name, i32 *name_len) const |
| i32 | IOCTL (u32 cmd, u8 *arg) const |
| i32 | Prepare (WaitHandle *event) const |
|
| static Socket | Create (i32 family, i32 type, i32 protocol) |
|
|
| MoveOnly (MoveOnly &&)=default |
|
MoveOnly & | operator= (MoveOnly &&)=default |
|
| MoveOnly (const MoveOnly &)=delete |
|
MoveOnly & | operator= (const MoveOnly &)=delete |
Owns a native socket. The destructor closes it, and a move leaves the source empty.
◆ Socket()
Takes ownership of a native socket.
- Parameters
-
| handle | The socket, or kInvalidSocket. |
◆ Accept()
| Socket rex::platform::Socket::Accept |
( |
sockaddr * | name, |
|
|
i32 * | name_len ) const |
Accepts a connection.
- Parameters
-
| name | Receives the peer address. |
| name_len | The size of the address buffer, then the size of the peer address. |
- Returns
- The connected socket, empty with GetSocketError set on failure.
◆ Bind()
| i32 rex::platform::Socket::Bind |
( |
const sockaddr * | name, |
|
|
i32 | name_len ) const |
Binds to an address.
- Returns
- 0 on success, -1 with GetSocketError set.
◆ Connect()
| i32 rex::platform::Socket::Connect |
( |
const sockaddr * | name, |
|
|
i32 | name_len ) const |
Connects to an address.
- Returns
- 0 on success, -1 with GetSocketError set.
◆ Create()
| Socket rex::platform::Socket::Create |
( |
i32 | family, |
|
|
i32 | type, |
|
|
i32 | protocol ) |
|
static |
Creates a native socket.
- Returns
- The socket, empty with GetSocketError set on failure.
◆ GetHandle()
Returns the native socket, kInvalidSocket when empty.
◆ GetLocalName()
| i32 rex::platform::Socket::GetLocalName |
( |
sockaddr * | name, |
|
|
i32 * | name_len ) const |
Reads the local address.
- Parameters
-
| name | Receives the local address. |
| name_len | The size of the address buffer, then the size of the local address. |
- Returns
- 0 on success, -1 with GetSocketError set.
◆ GetOption()
| i32 rex::platform::Socket::GetOption |
( |
i32 | level, |
|
|
i32 | name, |
|
|
void * | value, |
|
|
i32 * | len ) const |
Reads a socket option.
- Parameters
-
| value | Receives the option value. |
| len | The size of the value buffer, then the size of the value. |
- Returns
- 0 on success, -1 with GetSocketError set.
◆ GetPeerName()
| i32 rex::platform::Socket::GetPeerName |
( |
sockaddr * | name, |
|
|
i32 * | name_len ) const |
Reads the address of the connected peer.
- Parameters
-
| name | Receives the peer address. |
| name_len | The size of the address buffer, then the size of the peer address. |
- Returns
- 0 on success, -1 with GetSocketError set.
◆ IOCTL()
| i32 rex::platform::Socket::IOCTL |
( |
u32 | cmd, |
|
|
u8 * | arg ) const |
|
inline |
Runs an ioctl request through SocketIOCTL.
- Parameters
-
| arg | The argument buffer, read and written in place. |
- Returns
- 0 on success, or the platform error return value.
◆ Listen()
| i32 rex::platform::Socket::Listen |
( |
i32 | backlog | ) |
const |
Starts listening for connections.
- Parameters
-
| backlog | The length of the pending connection queue. |
- Returns
- 0 on success, -1 with GetSocketError set.
◆ Prepare()
| i32 rex::platform::Socket::Prepare |
( |
WaitHandle * | event | ) |
const |
|
inline |
Prepares the socket through SocketPrepare.
- Parameters
-
| event | A manual reset event whose Set ends a WaitSockets on the socket. |
- Returns
- 0 on success, or the platform error return value.
◆ Recv()
| i32 rex::platform::Socket::Recv |
( |
void * | buf, |
|
|
i32 | len, |
|
|
i32 | flags ) const |
Receives data.
- Returns
- The byte count, or -1 with GetSocketError set.
◆ RecvFrom()
| i32 rex::platform::Socket::RecvFrom |
( |
void * | buf, |
|
|
i32 | len, |
|
|
i32 | flags, |
|
|
sockaddr * | from, |
|
|
i32 * | from_len ) const |
Receives a datagram.
- Parameters
-
| from | Receives the sender address. |
| from_len | The size of the address buffer, then the size of the sender address. |
- Returns
- The byte count, or -1 with GetSocketError set.
◆ Send()
| i32 rex::platform::Socket::Send |
( |
const void * | buf, |
|
|
i32 | len, |
|
|
i32 | flags ) const |
Sends data. A send to a closed peer raises no signal.
- Returns
- The byte count, or -1 with GetSocketError set.
◆ SendTo()
| i32 rex::platform::Socket::SendTo |
( |
const void * | buf, |
|
|
i32 | len, |
|
|
i32 | flags, |
|
|
const sockaddr * | to, |
|
|
i32 | to_len ) const |
Sends a datagram. A send to a closed peer raises no signal.
- Parameters
-
| toThe | destination, null for the connected peer. |
- Returns
- The byte count, or -1 with GetSocketError set.
◆ SetOption()
| i32 rex::platform::Socket::SetOption |
( |
i32 | level, |
|
|
i32 | name, |
|
|
const void * | value, |
|
|
i32 | len ) const |
Sets a socket option.
- Returns
- 0 on success, -1 with GetSocketError set.
◆ Shutdown()
| i32 rex::platform::Socket::Shutdown |
( |
i32 | how | ) |
const |
Shuts a connection down.
- Returns
- 0 on success, -1 with GetSocketError set.
The documentation for this class was generated from the following file: