/* * Client socket class * * Encapsulates a socket for ease of use. * * Copyright (C) 2008 Alejandro Valenzuela Roca, * * http://mexinetica.com/~lanjoe9 * * This file is part of MotorJ, a free framework for videogame development. * * * * MotorJ is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MotorJ is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with MotorJ. If not, see . */ #ifndef CLIENTSOCKET_CLASS_H #define CLIENTSOCKET_CLASS_H #include #include #include #include #ifdef PC_SDL #include #endif #ifndef NINTENDO_WII #include #include #include #endif #ifdef NINTENDO_WII #include #include "wii_only/net_trans.h" #endif enum MJCLIENTSOCKETTYPE{ CS_IPV4TCP, CS_IPV4UDP, CS_IPV6TCP, CS_IPV6UDP}; class mjClientSocket { public: mjClientSocket(MJCLIENTSOCKETTYPE type, unsigned port); ~mjClientSocket(); unsigned GetPort(); MJCLIENTSOCKETTYPE GetType(); short DoConnect(char * address); bool IsConnected(); int SendData(void * data, unsigned length); int RecvData(void * data, unsigned maxlength); void DoDisconnect(); unsigned long GetOwnIP(); char * GetOwnIP_str(); unsigned long Who(); char * Who_str(); private: unsigned iport; MJCLIENTSOCKETTYPE itype; bool iconnected; int commSocket; struct sockaddr_in s_me; struct sockaddr_in s_to; struct sockaddr_in s_from; }; #endif