00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TCPSOCKET_HH_
00024 # define TCPSOCKET_HH_
00025
00026 #include "netsocket.hh"
00027
00028 namespace Network
00029 {
00032 class TcpSocket : public NetSocket
00033 {
00034 public:
00035 TcpSocket(SOCKET_VERSION version = V4) :
00036 NetSocket(TCP, version)
00037 {}
00038 TcpSocket(PROTO_KIND pkind, SOCKET_VERSION version = V4) :
00039 NetSocket(TCP, pkind, version)
00040 {}
00041 TcpSocket(int socket, SOCKET_VERSION version = V4) :
00042 NetSocket(TCP, version)
00043 {
00044 _socket = socket;
00045 }
00046 TcpSocket(int socket, PROTO_KIND pkind, SOCKET_VERSION version = V4) :
00047 NetSocket(TCP, pkind, version)
00048 {
00049 _socket = socket;
00050 }
00051
00052 virtual ~TcpSocket()
00053 {
00054 close();
00055 }
00056
00057 public:
00059
00101 void connect(const std::string& hostname, int port);
00103 std::string get_ip(TcpSocket *client) const;
00104
00106 TcpSocket* TcpSocket::accept() const;
00108
00154 void connect(int port);
00156 void close();
00157
00158 protected:
00165 std::string _read_line_bin(int socket, int& port,
00166 std::string& host, unsigned int psize);
00170 std::string _read_line_bin(int socket, unsigned int psize);
00171 };
00172 }
00173
00174 #endif