34 #ifndef _QORE_QORE_SOCKET_OBJECT_H
36 #define _QORE_QORE_SOCKET_OBJECT_H
38 #include <qore/QoreSocket.h>
39 #include <qore/AbstractPollableIoObjectBase.h>
40 #include <qore/QoreThreadLock.h>
47 class QoreSocketObject :
public AbstractPollableIoObjectBase {
48 friend class my_socket_priv;
49 friend hashdecl qore_httpclient_priv;
50 friend class SocketConnectPollOperation;
51 friend class SocketSendPollOperation;
52 friend class SocketRecvPollOperationBase;
53 friend class SocketRecvPollOperation;
54 friend class SocketRecvUntilBytesPollOperation;
55 friend class SocketUpgradeClientSslPollOperation;
56 friend class HttpClientConnectPollOperation;
59 DLLEXPORT QoreSocketObject();
62 DLLEXPORT
virtual void deref();
79 DLLEXPORT AbstractPollState* startConnect(
ExceptionSink* xsink,
const char* name);
90 DLLEXPORT AbstractPollState* startSslConnect(
ExceptionSink* xsink, X509* cert =
nullptr,
91 EVP_PKEY* pkey =
nullptr);
103 DLLEXPORT AbstractPollState* startSend(
ExceptionSink* xsink,
const char* data,
size_t size);
114 DLLEXPORT AbstractPollState* startRecv(
ExceptionSink* xsink,
size_t size);
127 DLLEXPORT AbstractPollState* startRecvUntilBytes(
ExceptionSink* xsink,
const char* pattern,
size_t size);
129 DLLEXPORT
int connect(
const char* name,
int timeout_ms,
ExceptionSink* xsink =
nullptr);
130 DLLEXPORT
int connectINET(
const char* host,
int port,
int timeout_ms,
ExceptionSink* xsink =
nullptr);
131 DLLEXPORT
int connectINET2(
const char* host,
const char* service,
int family,
int sock_type,
int protocol,
133 DLLEXPORT
int connectUNIX(
const char* p,
int socktype,
int protocol,
ExceptionSink* xsink =
nullptr);
134 DLLEXPORT
int connectSSL(
const char* name,
int timeout_ms,
ExceptionSink* xsink);
135 DLLEXPORT
int connectINETSSL(
const char* host,
int port,
int timeout_ms,
ExceptionSink* xsink);
136 DLLEXPORT
int connectINET2SSL(
const char* host,
const char* service,
int family,
int sock_type,
int protocol,
138 DLLEXPORT
int connectUNIXSSL(
const char* p,
int socktype,
int protocol,
ExceptionSink* xsink);
140 DLLEXPORT
int bind(
const char* name,
bool reuseaddr =
false);
142 DLLEXPORT
int bind(
int port,
bool reuseaddr =
false);
144 DLLEXPORT
int bind(
const char* iface,
int port,
bool reuseaddr =
false);
146 DLLEXPORT
int bindUNIX(
const char* name,
int socktype,
int protocol,
ExceptionSink* xsink);
147 DLLEXPORT
int bindINET(
const char* name,
const char* service,
bool reuseaddr,
int family,
int socktype,
151 DLLEXPORT
int getPort();
154 DLLEXPORT QoreSocketObject* accept(
int timeout_ms,
ExceptionSink* xsink);
155 DLLEXPORT QoreSocketObject* acceptSSL(
int timeout_ms,
ExceptionSink* xsink);
157 DLLEXPORT
int listen(
int backlog);
159 DLLEXPORT
int send(
const char* buf,
int size);
160 DLLEXPORT
int send(
const char* buf,
int size,
int timeout_ms,
ExceptionSink* xsink);
170 DLLEXPORT
int send(
int fd,
int size = -1);
172 DLLEXPORT
int sendi1(
char b,
int timeout_ms,
ExceptionSink* xsink);
173 DLLEXPORT
int sendi2(
short b,
int timeout_ms,
ExceptionSink* xsink);
174 DLLEXPORT
int sendi4(
int b,
int timeout_ms,
ExceptionSink* xsink);
176 DLLEXPORT
int sendi2LSB(
short b,
int timeout_ms,
ExceptionSink* xsink);
177 DLLEXPORT
int sendi4LSB(
int b,
int timeout_ms,
ExceptionSink* xsink);
191 DLLEXPORT
int recv(
int fd,
int size,
int timeout);
208 const char* http_version,
const QoreHashNode* headers,
const void* ptr,
int size,
int source,
int timeout_ms);
212 const char *path,
const char *http_version,
const QoreHashNode* headers,
217 const char* http_version,
const QoreHashNode* headers,
const void* data,
size_t size,
int source,
231 int source,
int timeout_ms,
bool* aborted =
nullptr);
234 DLLEXPORT
void sendHTTPChunkedBodyFromInputStream(
InputStream* is,
size_t max_chunked_size,
const int timeout_ms,
261 DLLEXPORT
int getPollableDescriptor()
const;
263 DLLEXPORT
int setSendTimeout(
int ms);
264 DLLEXPORT
int setRecvTimeout(
int ms);
265 DLLEXPORT
int getSendTimeout();
266 DLLEXPORT
int getRecvTimeout();
267 DLLEXPORT
int close();
268 DLLEXPORT
int shutdown();
270 DLLEXPORT
const char* getSSLCipherName();
271 DLLEXPORT
const char* getSSLCipherVersion();
272 DLLEXPORT
bool isSecure();
273 DLLEXPORT
long verifyPeerCertificate();
274 DLLEXPORT
int getSocket();
277 DLLEXPORT
bool isDataAvailable(
ExceptionSink* xsink,
int timeout = 0);
278 DLLEXPORT
bool isWriteFinished(
ExceptionSink* xsink,
int timeout = 0);
279 DLLEXPORT
bool isOpen()
const;
286 DLLEXPORT
int setNoDelay(
int nodelay);
287 DLLEXPORT
int getNoDelay();
289 DLLEXPORT
void setEventQueue(Queue* cbq,
ExceptionSink* xsink);
296 DLLEXPORT
void upgradeClientToSSL(
int timeout_ms,
ExceptionSink* xsink);
297 DLLEXPORT
void upgradeServerToSSL(
int timeout_ms,
ExceptionSink* xsink);
301 int64 min_ms = 1000);
303 DLLEXPORT
void clearStats();
304 DLLEXPORT
bool pendingHttpChunkedBody()
const;
305 DLLEXPORT
void setSslVerifyMode(
int mode);
306 DLLEXPORT
int getSslVerifyMode()
const;
307 DLLEXPORT
void acceptAllCertificates(
bool accept_all =
true);
308 DLLEXPORT
bool getAcceptAllCertificates()
const;
309 DLLEXPORT
bool captureRemoteCertificates(
bool set);
310 DLLEXPORT
QoreObject* getRemoteCertificate()
const;
311 DLLEXPORT
int64 getConnectionId()
const;
317 DLLEXPORT
void clearNonBlock();
323 my_socket_priv* priv;
325 DLLLOCAL
virtual ~QoreSocketObject();
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:57
holds arbitrary binary data
Definition: BinaryNode.h:41
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
Interface for private data of output streams.
Definition: OutputStream.h:44
defines string encoding functions in Qore
Definition: QoreEncoding.h:83
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:60
represents an X509 certificate, reference-counted, dynamically-allocated only
Definition: QoreSSLCertificate.h:42
provides access to a private key data structure for SSL connections
Definition: QoreSSLPrivateKey.h:40
provides access to sockets using Qore data structures
Definition: QoreSocket.h:127
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
base class for resolved call references
Definition: CallReferenceNode.h:109
a helper class for getting socket origination information
Definition: QoreSocket.h:74
intptr_t qore_offset_t
used for offsets that could be negative
Definition: common.h:76
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275