📄 serverdemo.cc
字号:
/**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 <stdlib.h>#include <assert.h>#include <string.h>#include <iostream.h>#include <stdlib.h>#include <unistd.h>#include "const.h"#include "string.h"#include "serverDemo.h"serverDemo :: serverDemo (char* new_service) : server (new_service){ service = NULL; packet = NULL; service = new char [ strlen (new_service) +1 ]; assert (service != NULL); strcpy (service, new_service);}serverDemo :: ~serverDemo (){ if (service != NULL) delete service; if (packet != NULL) delete packet;}void serverDemo :: start (){ cout << "\n### Hello !\n"; while (true) { if (listenUDP () == false) { sleep (1); continue; } cout << get_recived () << "\n"; answer ("### I'm a server. I've just recived message from You."); } cout << "\n### Goodbye !\n";}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -