Important Updates:

- DataTreeCore:
  - Allow types float, int & bool to be read as strings with GetStr()
- LogCore:
  - Add comments to Logging parameters
- WatchDogCore:
  - Call CSelectableCore::Process() in Process() to manage connect
- SelectableCore:
  - Allow SetSocketHandle() to be called if Handle already set as socket
  - added strlcase() method to convert string to lower case
  - Update Handle structure:
    - renamed Address -> HostName
    - renamed PortNo -> PortName
    - added AddressList for all resolved addresses
    - added AddressInfo for active address
  - Add ResolveAddress() method
    - Domain name and protocol port resolving with GetAddrInfo()
  - JSON updated:
    - domain name can be provided instead of IP address
    - protocol can be specified instead of Port No, e.g. "HTTP" / "SSH"
  - Resolve address before connect, or use next resolved address
This commit is contained in:
Charl Wentzel
2017-07-22 09:40:17 +02:00
parent c32875509d
commit aaf3c59727
6 changed files with 174 additions and 84 deletions

View File

@@ -87,9 +87,11 @@ struct SHandle {
pid_t ChildPID; // Forked child PID
char * Address; // Socket IP address
int PortNo; // Socket port no
bool KeepAlive; // Socket keep alive
char * HostName; // Host name or IP adddress
char * PortName; // Socket port no or protocol, e.g. "80" or "HTTP"
struct addrinfo * AddressList; // List of resolved IP Addresses for host name
struct addrinfo * AddressInfo; // Current selected IP Address
bool KeepAlive; // Socket keep alive
// Buffers
CRollingBuffer * InBuffer;
@@ -194,6 +196,7 @@ protected:
virtual int OpenForkPipe( THandle * Handle );
// Socket Operations
bool ResolveAddress( THandle * Handle );
virtual int OpenServerSocket( THandle * Handle );
virtual int OpenRemoteClientSocket( THandle * Handle );
virtual int OpenClientSocket( THandle * Handle );
@@ -208,6 +211,13 @@ protected:
// Specific operations
bool BuildArgs( const char * ExecPath, int &Count, char * Args[] );
// Convert string to lower case
inline char * strlcase( char * Str ) {
for (char * Ch = Str; *Ch; Ch++ )
*Ch = tolower(*Ch);
return Str;
}
public:
// Life Cycle
CSelectableCore( const char * Name, const char * pType = "Selectable" );
@@ -240,7 +250,7 @@ public:
// File Interface
bool SetPortHandle( THandle * Handle, const char * FileName );
bool SetForkPipeHandle( THandle * Handle, const char * ExecPath );
bool SetSocketHandle( THandle * Handle, EConnectType Type, const char * Address, const int PortNo, bool KeepAlive );
bool SetSocketHandle( THandle * Handle, EConnectType Type, const char * HostName, const char * PortName, bool KeepAlive );
bool ClearHandle( THandle * Handle );
// FD Operations