forked from hyphanet/lib-CppFCPLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.h
40 lines (30 loc) · 737 Bytes
/
Server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef SERVER_H__
#define SERVER_H__
#include <string>
#include <boost/asio.hpp>
#include <memory>
#include "Message.h"
namespace FCPLib {
class Server {
friend class NodeThread;
boost::asio::io_service io_service;
std::auto_ptr<boost::asio::ip::tcp::socket> socket_;
boost::asio::streambuf response;
std::istream response_stream;
Server(std::string& host, int port);
public:
~Server();
std::string readln();
void read(char*, std::size_t);
void send(const std::string &s);
void send(Message::Ptr m);
bool dataAvailable();
#ifdef _DEBUG_
static std::auto_ptr<Server> create_server(std::string& host, int port)
{
return std::auto_ptr<Server>( new Server(host, port) );
}
#endif
};
}
#endif