peerplays-fc/include/fc/tcp_socket.hpp

46 lines
885 B
C++
Raw Normal View History

2012-09-27 23:48:48 +00:00
#ifndef _FC_TCP_SOCKET_HPP_
#define _FC_TCP_SOCKET_HPP_
#include <fc/utility.hpp>
#include <fc/fwd.hpp>
namespace fc {
namespace ip { class endpoint; }
class tcp_socket {
public:
tcp_socket();
~tcp_socket();
void connect_to( const fc::ip::endpoint& e );
void write( const char* buffer, size_t len );
size_t readsome( char* buffer, size_t max );
size_t read( char* buffer, size_t s );
2012-10-22 00:54:52 +00:00
bool is_open()const;
2012-10-10 01:40:29 +00:00
void flush();
2012-09-27 23:48:48 +00:00
private:
friend class tcp_server;
class impl;
fc::fwd<impl,32> my;
};
class tcp_server {
public:
2012-10-10 01:40:29 +00:00
tcp_server(uint16_t port=0);
2012-09-27 23:48:48 +00:00
~tcp_server();
2012-10-17 01:48:09 +00:00
void close();
2012-09-27 23:48:48 +00:00
bool accept( tcp_socket& s );
2012-10-10 01:40:29 +00:00
// void listen( uint16_t port );
2012-09-27 23:48:48 +00:00
private:
class impl;
fc::fwd<impl,32> my;
};
} // namesapce fc
#endif // _FC_TCP_SOCKET_HPP_