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

RealSocket.h

Ugrás a fájl dokumentációjához.
00001 /*
00002     mySocket, RealSocket
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 REALSOCKET_H
00020 #define REALSOCKET_H
00021 
00022 #include <Socket.h>
00023 #include <iostream>
00024 #include <string>
00025 
00026 using namespace std;
00027 
00028 class RealSocket : public Socket { /* finished, do not inherit this class! */
00029 
00030   friend class SocketHandler;
00031   friend class ConnectSocket;
00032 
00033   public:
00034 
00035     RealSocket(socket_t _sock);
00036     string GetReadBuf();
00037     int GetReadLen();
00038     string GetWriteBuf();
00039     int GetWriteLen();
00040 
00041     void Write(string str);
00042     bool IsConnected();
00043 
00044   private:
00045 
00046     int WriteBuffer(string writeval);
00047     int WriteBuffer(void* writeval, int writelen);
00048     int WriteBuffer(char* writeval);
00049     int Read(string& readval);
00050     int Read(void* readval, int readlen);
00051 //    int readfrom(void* readval, int readlen, struct sockaddr* from, socklen_t* fromlen);
00052 
00053     void OnRead();
00054     void OnWrite();
00055     void OnConnectionError(); // not used yet
00056 
00057     virtual void __OnConnClosed() {}
00058     virtual void __OnConnected() {}
00059     virtual void __OnRead() = 0;
00060     virtual void __OnClose() = 0;
00061     virtual void __OnReadError() = 0;
00062 
00063     string ReadBuf;
00064     string WriteBuf;
00065     int ReadLen;
00066     int WriteLen;
00067         
00068   };
00069 
00070 RealSocket* operator<<(RealSocket* _socket, string str);
00071 RealSocket* operator+=(RealSocket* _socket, string str);
00072 
00073 #endif
00074 

SourceForge.netLogo