Főoldal | Névtérlista | Osztályhierarchia | Betűrendes lista | Adatszerkezetek | Könyvtárak | Fájllista | Névtértagok | Adatmezők | Globális elemek

ListenServer.h

Ugrás a fájl dokumentációjához.
00001 /*
00002     mySocket, ListenServer
00003     Copyright (C) 2006  Kornel Csernai <csko@csko.hu>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 */
00019 #ifndef LISTENSERVER_H
00020 #define LISTENSERVER_H
00021 
00022 #include <Socket.h>
00023 #include <SocketHandler.h>
00024 #include <Errors.h>
00025 #include <iostream>
00026 
00027 using namespace std;
00028 
00029 const int backlog = 5;
00030 
00031 class ListenServer : public Socket {
00032 
00033   friend class SocketHandler;
00034 
00035   public:
00036 
00037     ListenServer();
00038     virtual ~ListenServer();
00039 
00040     void Start(int _port, string _addr, SocketType type = TYPE_TCP);
00041     void Start(struct sockaddr_in _saddr, SocketType _type = TYPE_TCP);
00042     void Stop();
00043 
00044   private:
00045 
00046     bool running;
00047 
00048     void Listen(int opt);
00049     void Bind(string host, int port);
00050         void Bind();
00051 
00052     virtual void __OnAccept(); // has default
00053     virtual void __OnAcceptFailed(){}
00054     virtual void __OnRead(){}
00055     virtual void __OnClose(){}
00056     virtual void __OnReadError(){}
00057     virtual void __OnConnected(){}
00058     virtual void __OnConnClosed(){}
00059 
00060     void OnAccept();
00061     void OnAcceptFailed();
00062     void OnClose();
00063 
00064   protected:
00065   
00066     int Accept(sockaddr_in &_saddr);
00067 
00068   };
00069 
00070 #endif

SourceForge.netLogo