Major update:

- Converted CSocketCore to Class/Object
- Implemented CFunctionCore as base class for CPortCore and CSocketCore
- Moved common functions to CFunctionCore and renamed
  eg. Maintain() -> Process()
- Pass Objects directly to each other as OutputFunction
- New Input() method allows data transfer between objects
This commit is contained in:
Charl Wentzel
2016-05-19 15:10:55 +02:00
parent e222d51997
commit 0d1c46ac53
8 changed files with 370 additions and 205 deletions

View File

@@ -9,7 +9,7 @@
#define REDACORE_SOCKETCORE_H_
// redA Libraries
/* none */
#include "FunctionCore.h"
// Standard C/C++ Libraries
/* none */
@@ -24,19 +24,43 @@ typedef enum { ssNone = 0, ssWaitingtoOpen = 1, ssOpen = 2, ssDataWaiting = 3, s
const char SocketStateName[][15] = { "None", "WaitingToOpen", "Open", "DataWaiting", "Closed", "Failed" };
//---------------------------------------------------------------------------
// Socket Functions
int OpenTCPserverSocket( const char *pServerName, const char *ServerAddress, int PortNo, bool KeepAlive );
int OpenTCPinClientSocket();
int OpenTCPoutClientSocket( const char *pServerName, const char *ServerAddress, int PortNo, bool KeepAlive );
// Port Core Class
class CSocketCore : public CFunctionCore
{
protected:
char ServerAddress[25];
int PortNo;
char ClientAddress[25];
ESocketState GetServerState();
ESocketState GetClientState();
int ServerHandle;
ESocketState ServerState;
bool CloseTCPSocket( ESockConnectType SocketType );
int ClientHandle;
ESocketState ClientState;
bool ReadClientSocket();
bool MaintainSocket( int PortHandle );
public:
// Life Cycle
CSocketCore( const char * ServerName );
virtual ~CSocketCore();
// Socket Functions
int OpenTCPserverSocket( const char *ServerAddress, int PortNo, bool KeepAlive );
int OpenTCPinClientSocket();
int OpenTCPoutClientSocket( const char *ServerAddress, int PortNo, bool KeepAlive );
ESocketState GetServerState();
ESocketState GetClientState();
bool CloseTCPSocket( ESockConnectType SocketType );
int GetServerFD() { return ServerHandle; };
int GetClientFD() { return ClientHandle; };
virtual int Input( int InputID, char * Buffer, int BufLen );
virtual bool Read( int FD );
virtual bool ProcessBuffer( bool Force );
};
//---------------------------------------------------------------------------
#endif /* REDACORE_SOCKETCORE_H_ */