C++ TargetRTS
Loading...
Searching...
No Matches
RTTcpSocket.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTTcpSocket_h__
11#define __RTTcpSocket_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTConfig_h__
18#include <RTConfig.h>
19#endif
20
21class RTIOMonitor;
22
24{
25public:
26 RTTcpSocket( void );
27 ~RTTcpSocket( void );
28
29 void registerWith( RTIOMonitor * );
30
31 int create( void );
32 void close( void );
33
34 int listen( int port );
35 int acceptFrom( const RTTcpSocket & listener );
36
37 int getPrimary( char * ip_address ) const;
38 static int lookup( const char * host, char * ip_address );
39 static int lookup_numeric( const char * host, char * ip_address );
40
41 int connect( const char * address, int port );
42
43 int hasData( void );
44 int read( char *, int );
45 int write( const char *, int );
46
47 enum State { Closed, Listen, SynSent, Established };
48
49 State state( void );
50
51 int getLocalName( char *, int ) const;
52 int getLocalPort( void ) const;
53
54 void setMaxPendingConnections(int);
55
56#ifdef ENABLEIPv6
57 enum { IpAddressSize = 16 };
58#else
59 enum { IpAddressSize = 4 };
60#endif
61
62protected:
63 int _sd;
64 State _state;
65 RTIOMonitor * _monitor;
66
67 int _max_pending_connections;
68
69 // support for non-blocking connect
70 char _peer_ip[ IpAddressSize ];
71 int _peer_port;
72
73 int try_connect( void );
74
75private:
76 // unavailable methods
77 RTTcpSocket( const RTTcpSocket & );
78 RTTcpSocket & operator=( const RTTcpSocket & );
79};
80
81#endif // __RTTcpSocket_h__
Definition: RTIOMonitor.h:24
Definition: RTTcpSocket.h:24