|
Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
#include <network.h>
Public Member Functions | |
| ServerSocket () | |
| Construct a new empty Server Socket object. | |
| ServerSocket (int type) | |
| Construct a new Server Socket object. | |
| ~ServerSocket ()=default | |
| Destroy the Server Socket object. | |
| bool | bind (const char *address, int port) const |
| Binds the server to port / address. | |
| void | start (unsigned int backlog) const |
| Starts the server. | |
| ClientSocket | accept () const |
| Accepts a new client. | |
| void | close () const |
| Closes the connection. | |
Static Public Member Functions | |
| static bool | init () |
| Inits the POSIX API. | |
| static bool | cleanup () |
| Cleansup the POSIX API. | |
Network POSIX Server.
Wrapper for cross-platform POSIX networking.
|
default |
Construct a new empty Server Socket object.
Only used for late initialization, any call on an object initialized that way will fail.
| ServerSocket::ServerSocket | ( | int | type | ) |
Construct a new Server Socket object.
Creates a server using the POSIX api.
| type | the socket type, please use SOCK_STREAM |
| ClientSocket ServerSocket::accept | ( | ) | const |
Accepts a new client.
Accepts asynchronously a new client, and gives back a wrapper for the client socket when the client is connected.
Binds the server to port / address.
Binds the server to a specific address and port to listen on.
| address | the address to bind on |
| port | the port to bind on |
|
static |
Cleansup the POSIX API.
Akin to ServerSocket::init(), we need also to cleanup windows mess ! Thanks again windows ! It will never fail on a Linux Machine.
| void ServerSocket::close | ( | ) | const |
Closes the connection.
Manually closes the connection, should be always ran when you finished your stuff.
|
static |
Inits the POSIX API.
Because windows is not capable of making correct APIs, we need to initialize it, in the case we are running this code on a windows machine... Thanks windows ! It will never fail on a Linux Machine.
Starts the server.
Starts listening for incoming connections, with a max "acceptance" of incoming connections of backlog
| backlog | the max incoming connections |