Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

Socket.h

00001 /*
00002    Copyright (C) 2002 the Strongroom project
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    @author Ewald Snel
00010    @author Denis de Leeuw Duarte
00011 */
00012 
00013 #ifndef __SOCKET_H_
00014 #define __SOCKET_H_
00015 
00016 #include <inttypes.h>
00017 #include <string>
00018 
00019 #define ASCII_MAX_LENGTH        255
00020 
00021 
00022 using namespace std;
00023 
00027 class Socket
00028 {
00029 public:
00030     Socket();
00031 
00035     virtual ~Socket() = 0;
00036 
00042     int writeLine( string msg );
00043 
00050     int writeLine( const char *msg );
00051 
00058     bool startBinaryTransfer( int64_t length, int packetSize );
00059 
00066     int readBinary( uint8_t *buffer, int maxlen );
00067 
00074     int writeBinary( const uint8_t *buffer, int length );
00075 
00081     virtual int readLine( string &msg ) = 0;
00082 
00086     virtual void interrupt() = 0;
00087 
00091     virtual void close();
00092 
00093 protected:
00100     virtual int readBlock( void *buffer, int maxlen ) = 0;
00101 
00108     virtual int writeBlock( const void *buffer, int length ) = 0;
00109 
00110 private:
00116     int getTransferLength( int length );
00117 
00127     int codec( uint8_t *&buffer, int &length, int transfer, bool enc );
00128 
00129     int64_t binaryOffset, binaryLength;
00130     int binaryPacket, binaryIndex;
00131     uint8_t *binaryBuffer;
00132 };
00133 
00134 #endif

Generated on Wed Feb 18 13:45:55 2004 for strongroom by doxygen1.2.18