cnet::Socket is a wrapper around the native socket implementation of each os
class Socket
{
public:
Socket(int type, int protocol);
~Socket();
private:
cnet::SocketHandle socketId;
cnet::Address peerAddress;
cnet::Address sockAddress;
int type;
int protocol;
};
| Name | Description | Return type |
|---|---|---|
| Close | Closes the socket | void |
| Listen | Start listening to new connections | void |
| Bind | Binds the socket to the specified address | bool |
| Connect | Connect to a server on the specified address | bool |
| Accept | Accept a pending connection | std::shared_ptr<cnet::Socket> |
| Recv | Receive the specified amount of bytes | cnet::Bytes |
| RecvFrom | Receive data from the socket | std::pair<cnet::Address, cnet::Bytes> |
| Peek | Peek at the current data with the specified amount | cnet::Bytes |
| Send | Send data to the connected socket | int |
| SendTo | Send data to the specified address | int |
| GetPeerAddress | Returns the peer address of the socket | cnet::Address |
| GetSockAddress | Returns the socket's address | cnet::Address |
| GetHandle | Returns the socket's native handle | cnet::SocketHandle |