# tcp.h

Go to the documentation of this file.

    00001 /* $Id: tcp.h 15206 2009-01-22 10:09:56Z rubidium $ */
    00002
    00007 #ifndef NETWORK_CORE_TCP_H
    00008 #define NETWORK_CORE_TCP_H
    00009
    00010 #ifdef ENABLE_NETWORK
    00011
    00012 #include "os_abstraction.h"
    00013 #include "address.h"
    00014 #include "core.h"
    00015 #include "packet.h"
    00016
    00018 class NetworkTCPSocketHandler : public NetworkSocketHandler {
    00019 private:
    00020   Packet *packet_queue;
    00021   Packet *packet_recv;
    00022 public:
    00023   bool writable;
    00024
    00025   virtual NetworkRecvStatus CloseConnection();
    00026   void Send_Packet(Packet *packet);
    00027   bool Send_Packets();
    00028   bool IsPacketQueueEmpty();
    00029
    00030   Packet *Recv_Packet(NetworkRecvStatus *status);
    00031
    00032   NetworkTCPSocketHandler(SOCKET s = INVALID_SOCKET);
    00033   ~NetworkTCPSocketHandler();
    00034 };
    00035
    00039 class TCPConnecter {
    00040 private:
    00041   class ThreadObject *thread;
    00042   bool connected;
    00043   bool aborted;
    00044   bool killed;
    00045   SOCKET sock;
    00046
    00048   void Connect();
    00049
    00054   static void ThreadEntry(void *param);
    00055
    00056 protected:
    00058   NetworkAddress address;
    00059
    00060 public:
    00065   TCPConnecter(const NetworkAddress &address);
    00067   virtual ~TCPConnecter() {}
    00068
    00073   virtual void OnConnect(SOCKET s) {}
    00074
    00078   virtual void OnFailure() {}
    00079
    00086   static void CheckCallbacks();
    00087
    00089   static void KillAll();
    00090 };
    00091
    00092 #endif /* ENABLE_NETWORK */
    00093
    00094 #endif /* NETWORK_CORE_TCP_H */