⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 server.h

📁 C++ TCPIP and UDPIP library of classes
💻 H
字号:
/**C++ tcp/ip and udp/ip library and example programmCopyright (C) 2002  Marcin Caban 'Cabko' and Borys Wisniewski 'Boria'This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, orany later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.http://www.gnu.org/Marcin Cabane-mail: cabko@polsl.gliwice.plphone: +48 501 452 123Borys Wisniewskie-mail: boria@polsl.gliwice.plphone: +48 503 065 996*/#include "tcpip.h"#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>/**  Class for communicating with clients.  Implements network %server.  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/class server : public tcpip{ public:/**  Default constructor.  Initialize variables.  Opens UDP socket for listening.  \param  service listen port number  \todo   Make availability to open TCP as well as UDP socket.  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/  server (char* service);/**  Default destructor.  Free any allocated momory. Closes any open sockets.  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/  ~server (); protected:/**  Returns last recived data.  \return recived string  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/  char* get_recived();/**  Sends data (string) to the %client.  \param  packet a string to send  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/  void answer (char* packet);/**  Starts listening for %client, recives data from %client on UDP port.  \return "true" if everything is OK or "false" if there is an error  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/  bool listenUDP ();/**  Starts listening for %client, recives data from %client on TCP port.  \return "true" if everything is OK or "false" if there is an error  \todo   implenent this function (now it is just a copy of listenUDP)  \author Marcin Caban  \date   Thu Jan 17 01:41:18 2002*/  bool listenTCP (); private:/**  Last recived string.  Stores last recived data from a %server.*/  char* recived;/**  Server socket.  Stores %server socket.*/  int sock;  struct sockaddr_in addr;  socklen_t addr_len;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -