Samchon Framework for CPP
1.0.0
|
#include <Server.hpp>
Public Member Functions | |
Server () | |
virtual | ~Server () |
virtual void | open (int port) |
virtual void | close () |
Protected Member Functions | |
virtual void | addClient (std::shared_ptr< ClientDriver >)=0 |
A server.
The Server is an abstract class providing methods for opening a server and accepting clients. The server opened by this Server class follows the protocol of Samchon Framework's own.
To open a server, extends the Server class and overrides addClient() method to define what to do with a newly connected remote clients. At last, call open() method with the specified port number.
Below codes and classes will be good examples for comprehending how to open a server and handle remote clients.
Note that, this Server class follows the protocol of Samchon Framework's own. If you want to provide a realtime web-service, then use WebServer instead, that is following the web-socket protocol.
Protocol | Derived Type | Related ClientDriver |
---|---|---|
Samchon Framework's own | Server | ClientDriver |
Web-socket protocol | WebServer | WebClientDriver |
Definition at line 45 of file Server.hpp.
|
inline |
Default Constructor.
Definition at line 54 of file Server.hpp.
|
inlinevirtual |
Default Destructor.
Reimplemented in samchon::templates::service::Server.
Definition at line 61 of file Server.hpp.
References close().
|
inlinevirtual |
Open server.
port | Port number to open. |
Definition at line 74 of file Server.hpp.
Referenced by samchon::templates::parallel::MediatorServer::start().
|
inlinevirtual |
Close the server.
Definition at line 100 of file Server.hpp.
References addClient().
Referenced by ~Server().
|
protectedpure virtual |
Add a newly connected remote client.
The addClient() is an abstract method being called when a remote client is newly connected with IClientDriver object who communicates with the remote system. Overrides this method and defines what to do with the driver, a newly connected remote client.
Below methods and example codes may be good for comprehending how to utilizing this addClient method.
driver | A communicator with (newly connected) remote client. |
Referenced by close(), and samchon::protocol::WebServer::WebServer().