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>
47class QoreSocketObject :
public AbstractPollableIoObjectBase {
48 friend class my_socket_priv;
49 friend struct qore_httpclient_priv;
50 friend class SocketPollSocketOperationBase;
51 friend class SocketConnectPollOperation;
52 friend class SocketAcceptPollSocketOperationBase;
53 friend class SocketAcceptPollOperation;
54 friend class SocketSendPollOperation;
55 friend class SocketRecvPollOperationBase;
56 friend class SocketRecvPollOperation;
57 friend class SocketRecvDataPollOperation;
58 friend class SocketReadHttpHeaderPollOperation;
59 friend class SocketRecvUntilBytesPollOperation;
60 friend class SocketUpgradeClientSslPollOperation;
61 friend class SocketUpgradeServerSslPollOperation;
62 friend class HttpClientConnectPollOperation;
65 DLLEXPORT QoreSocketObject();
67 DLLEXPORT QoreSocketObject(QoreSocketObject& orig,
int descriptor);
70 DLLEXPORT
virtual void deref();
87 DLLEXPORT AbstractPollState* startConnect(
ExceptionSink* xsink,
const char* name);
96 DLLEXPORT AbstractPollState* startSslConnect(
ExceptionSink* xsink);
108 DLLEXPORT AbstractPollState* startSend(
ExceptionSink* xsink,
const char* data,
size_t size);
119 DLLEXPORT AbstractPollState* startAccept(
ExceptionSink* xsink);
128 DLLEXPORT AbstractPollState* startSslAccept(
ExceptionSink* xsink);
139 DLLEXPORT AbstractPollState* startRecv(
ExceptionSink* xsink,
size_t size);
152 DLLEXPORT AbstractPollState* startRecvUntilBytes(
ExceptionSink* xsink,
const char* pattern,
size_t size);
162 DLLEXPORT AbstractPollState* startRecvPacket(
ExceptionSink* xsink);
164 DLLEXPORT
int connect(
const char* name,
int timeout_ms,
ExceptionSink* xsink =
nullptr);
165 DLLEXPORT
int connectINET(
const char* host,
int port,
int timeout_ms,
ExceptionSink* xsink =
nullptr);
166 DLLEXPORT
int connectINET2(
const char* host,
const char* service,
int family,
int sock_type,
int protocol,
168 DLLEXPORT
int connectUNIX(
const char* p,
int socktype,
int protocol,
ExceptionSink* xsink =
nullptr);
169 DLLEXPORT
int connectSSL(
ExceptionSink* xsink,
const char* name,
int timeout_ms);
170 DLLEXPORT
int connectINETSSL(
ExceptionSink* xsink,
const char* host,
int port,
int timeout_ms);
171 DLLEXPORT
int connectINET2SSL(
ExceptionSink* xsink,
const char* host,
const char* service,
int family,
172 int sock_type,
int protocol,
int timeout_ms = -1);
173 DLLEXPORT
int connectUNIXSSL(
ExceptionSink* xsink,
const char* p,
int socktype,
int protocol);
175 DLLEXPORT
int bind(
const char* name,
bool reuseaddr =
false);
177 DLLEXPORT
int bind(
int port,
bool reuseaddr =
false);
179 DLLEXPORT
int bind(
const char* iface,
int port,
bool reuseaddr =
false);
181 DLLEXPORT
int bindUNIX(
const char* name,
int socktype,
int protocol,
ExceptionSink* xsink);
182 DLLEXPORT
int bindINET(
const char* name,
const char* service,
bool reuseaddr,
int family,
int socktype,
186 DLLEXPORT
int getPort();
189 DLLEXPORT QoreSocketObject* accept(
int timeout_ms,
ExceptionSink* xsink);
190 DLLEXPORT QoreSocketObject* acceptSSL(
ExceptionSink* xsink,
int timeout_ms);
192 DLLEXPORT
int listen(
int backlog);
194 DLLEXPORT
int send(
const char* buf,
int size);
195 DLLEXPORT
int send(
const char* buf,
int size,
int timeout_ms,
ExceptionSink* xsink);
205 DLLEXPORT
int send(
int fd,
int size = -1);
207 DLLEXPORT
int sendi1(
char b,
int timeout_ms,
ExceptionSink* xsink);
208 DLLEXPORT
int sendi2(
short b,
int timeout_ms,
ExceptionSink* xsink);
209 DLLEXPORT
int sendi4(
int b,
int timeout_ms,
ExceptionSink* xsink);
211 DLLEXPORT
int sendi2LSB(
short b,
int timeout_ms,
ExceptionSink* xsink);
212 DLLEXPORT
int sendi4LSB(
int b,
int timeout_ms,
ExceptionSink* xsink);
226 DLLEXPORT
int recv(
int fd,
int size,
int timeout);
243 const char* http_version,
const QoreHashNode* headers,
const void* ptr,
int size,
int source,
int timeout_ms);
247 const char *path,
const char *http_version,
const QoreHashNode* headers,
252 const char* http_version,
const QoreHashNode* headers,
const void* data,
size_t size,
int source,
266 int source,
int timeout_ms,
bool* aborted =
nullptr);
269 DLLEXPORT
void sendHTTPChunkedBodyFromInputStream(
InputStream* is,
size_t max_chunked_size,
const int timeout_ms,
302 DLLEXPORT
int getPollableDescriptor()
const;
304 DLLEXPORT
int setSendTimeout(
int ms);
305 DLLEXPORT
int setRecvTimeout(
int ms);
306 DLLEXPORT
int getSendTimeout();
307 DLLEXPORT
int getRecvTimeout();
308 DLLEXPORT
int close();
309 DLLEXPORT
int shutdown();
311 DLLEXPORT
const char* getSSLCipherName();
312 DLLEXPORT
const char* getSSLCipherVersion();
313 DLLEXPORT
bool isSecure();
314 DLLEXPORT
long verifyPeerCertificate();
315 DLLEXPORT
int getSocket();
318 DLLEXPORT
bool isDataAvailable(
ExceptionSink* xsink,
int timeout = 0);
319 DLLEXPORT
bool isWriteFinished(
ExceptionSink* xsink,
int timeout = 0);
320 DLLEXPORT
bool isOpen()
const;
327 DLLEXPORT
int setNoDelay(
int nodelay);
328 DLLEXPORT
int getNoDelay();
330 DLLEXPORT
void setEventQueue(Queue* cbq,
ExceptionSink* xsink);
334 DLLEXPORT
void upgradeClientToSSL(
ExceptionSink* xsink,
int timeout_ms = -1);
335 DLLEXPORT
void upgradeServerToSSL(
ExceptionSink* xsink,
int timeout_ms = -1);
339 int64 min_ms = 1000);
341 DLLEXPORT
void clearStats();
342 DLLEXPORT
bool pendingHttpChunkedBody()
const;
343 DLLEXPORT
void setSslVerifyMode(
int mode);
344 DLLEXPORT
int getSslVerifyMode()
const;
345 DLLEXPORT
void acceptAllCertificates(
bool accept_all =
true);
346 DLLEXPORT
bool getAcceptAllCertificates()
const;
347 DLLEXPORT
bool captureRemoteCertificates(
bool set);
348 DLLEXPORT
QoreObject* getRemoteCertificate()
const;
349 DLLEXPORT
int64 getConnectionId()
const;
355 DLLEXPORT
void clearNonBlock();
361 my_socket_priv* priv;
363 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:50
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:51
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition QoreObject.h:61
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:129
Qore's string value type, reference counted, dynamically-allocated only.
Definition QoreStringNode.h:50
base class for resolved call references
Definition CallReferenceNode.h:115
a helper class for getting socket origination information
Definition QoreSocket.h:76
intptr_t qore_offset_t
used for offsets that could be negative
Definition common.h:82
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:266
The main value class in Qore, designed to be passed by value.
Definition QoreValue.h:279