Important Update:

- SelectableCore:
  - Bug fix: StateCallBack array to small
  - Implemented and tested UNIX sockets
  - Started implementation of UDP sockets
  - Add "TCP" to TCP socket related methods and types
This commit is contained in:
Charl Wentzel
2018-11-18 18:29:20 +02:00
parent 85a811c19f
commit 1e74b9cd60
2 changed files with 520 additions and 56 deletions

View File

@@ -17,8 +17,9 @@
//---------------------------------------------------------------------------
// Types required for connections
typedef enum { ctNone = 0, ctSerial = 1, ctLinePrinter = 2, ctServer = 3, ctRemoteClient = 4, ctClient = 5, ctForkPipe = 6 } EConnectType;
const char ConnectTypeName[][15] = { "None", "SerialPort", "ParallelPort", "Server", "RemoteClient", "Client", "ForkPipe" };
typedef enum { ctNone = 0, ctSerial = 1, ctLinePrinter = 2, ctForkPipe = 3, ctUNIXserver = 4, ctUNIXclient = 5, ctUNIXremote = 6,
ctUDPsock = 7, ctTCPserver = 8, ctTCPremote = 9, ctTCPclient = 10 } EConnectType;
const char ConnectTypeName[][20] = { "None", "Serial", "LinePrinter", "ForkPipe", "UNIXserver", "UNIXclient", "UNIXremote", "UDPsock", "TCPserver", "TCPremote", "TCPclient" };
typedef enum { csNone = 0, csOpenRequest = 1, csWaitingtoOpen = 2, csOpen = 3, csDataWaiting = 4, csClosed = 5, csFailed = 6 } EConnectState;
const char ConnectStateName[][15] = { "None", "OpenRequest", "WaitingToOpen", "Open", "DataWaiting", "Closed", "Failed" };
@@ -84,7 +85,7 @@ struct SHandle {
long CloseTimeout; // millisecs of no traffic before closing socket
// Callback functions
FHandleCallback StateCallback[ 6 ];
FHandleCallback StateCallback[ 7 ];
// Type specific parameters
char * Path; // Port (file)name or Exec path
@@ -209,14 +210,18 @@ protected:
int OpenLinePrinterPort( THandle * Handle );
// ForkPipe Operations
// File Socket Operations
int OpenForkPipe( THandle * Handle );
int OpenUNIXserverSocket( THandle * Handle );
int OpenUNIXclientSocket( THandle * Handle );
int OpenUNIXremoteSocket( THandle * Handle );
// Socket Operations
bool ResolveAddress( THandle * Handle, bool DelayResolve );
int OpenServerSocket( THandle * Handle, bool DelayResolve );
int OpenRemoteClientSocket( THandle * Handle );
int OpenClientSocket( THandle * Handle, bool DelayResolve );
int OpenUDPsocket( THandle * Handle, bool DelayResolve );
int OpenTCPserverSocket( THandle * Handle, bool DelayResolve );
int OpenTCPremoteSocket( THandle * Handle );
int OpenTCPclientSocket( THandle * Handle, bool DelayResolve );
// Mutual Operations
int ReadFromFD( int FD, char * Data, int MaxLen );
@@ -270,6 +275,7 @@ public:
bool SetSerialHandleConfig( THandle * Handle, int Baudrate, short DataBits, short Parity, short StopBits, short FlowCtrl, int DataWait );
bool SetLinePrinterHandle( THandle * Handle, const char * FileName );
bool SetForkPipeHandle( THandle * Handle, const char * ExecPath );
bool SetUnixHandle( THandle * Handle, EConnectType Type, const char * FileName );
bool SetSocketHandle( THandle * Handle, EConnectType Type, const char * HostName, const char * PortName, long ResolveDelay );
bool ClearHandle( THandle * Handle );