00001 #ifndef _CONNECTION_H_ 00002 #define _CONNECTION_H_ 00003 00004 #include "Winsock2.h" 00005 #include "../util/log.h" 00006 00007 class Connection{ 00008 private: 00009 SOCKET tcp; 00010 SOCKET ls; 00011 int port; 00012 struct sockaddr_in sin; 00013 bool isConnected; 00014 bool isOpen; 00015 00016 Connection(SOCKET s); 00017 public: 00018 Connection(int port); 00019 virtual ~Connection() {closesocket(tcp);}; 00020 Connection *waitForConnection(); 00021 int connectByIp(char *addr); 00022 int disconnect(); 00023 int recieveData(char *buf, int size, int flag); 00024 int sendData(char *buf, int size); 00025 int getLastError(); 00026 int getPort(); 00027 }; 00028 00029 00030 #endif