Qore Programming Language 2.0.0
Loading...
Searching...
No Matches
QoreSocket.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 QoreSocket.h
4
5 IPv4, IPv6, unix socket class with SSL support
6
7 Qore Programming Language
8
9 Copyright (C) 2003 - 2024 Qore Technologies, s.r.o.
10
11 will unlink (delete) UNIX domain socket files when closed
12
13 Permission is hereby granted, free of charge, to any person obtaining a
14 copy of this software and associated documentation files (the "Software"),
15 to deal in the Software without restriction, including without limitation
16 the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 and/or sell copies of the Software, and to permit persons to whom the
18 Software is furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in
21 all copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 DEALINGS IN THE SOFTWARE.
30
31 Note that the Qore library is released under a choice of three open-source
32 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
33 information.
34*/
35
36#ifndef _QORE_QORESOCKET_H
37
38#define _QORE_QORESOCKET_H
39
40#include <qore/Qore.h>
41#include <qore/InputStream.h>
42#include <qore/OutputStream.h>
43#include <qore/AbstractPollState.h>
44
45#include <cctype>
46#include <cstdlib>
47#include <cstring>
48#include <strings.h>
49#include <sys/types.h>
50#include <unistd.h>
51
52#include <openssl/ssl.h>
53#include <openssl/err.h>
54
55#define QSE_MISC_ERR 0
56#define QSE_RECV_ERR -1
57#define QSE_NOT_OPEN -2
58#define QSE_TIMEOUT -3
59#define QSE_SSL_ERR -4
60#define QSE_IN_OP -5
61#define QSE_IN_OP_THREAD -6
62
63// forward references
64class Queue;
67
69
77 friend hashdecl qore_socket_private;
78
79private:
80 hashdecl qore_socketsource_private *priv; // private implementation
81
83 DLLLOCAL SocketSource(const SocketSource&);
84
86 DLLLOCAL SocketSource& operator=(const SocketSource&);
87
88public:
90 DLLEXPORT SocketSource();
91
93 DLLEXPORT ~SocketSource();
94
96
99
101
104
106
108 DLLEXPORT const char* getAddress() const;
109
111
113 DLLEXPORT const char* getHostName() const;
114
115 DLLLOCAL void setAll(QoreObject* o, ExceptionSink* xsink);
116};
117
119
130 friend hashdecl qore_socket_private;
131 friend hashdecl qore_httpclient_priv;
132 friend class QoreSocketObject;
133 friend class QoreFtpClient;
134 friend class HttpClientRecvHeaderPollState;
135 friend class HttpClientRecvChunkedPollState;
136 friend class HttpClientRecvUntilClosePollState;
137 friend class HttpClientConnectSendRecvPollOperation;
138 friend class SocketAcceptPollOperation;
139 friend class SocketReadHttpHeaderPollOperation;
140 friend class my_socket_priv;
141
142public:
144 DLLEXPORT QoreSocket();
145
147 DLLEXPORT ~QoreSocket();
148
150
160 DLLEXPORT AbstractPollState* startConnect(ExceptionSink* xsink, const char* name);
161
163
172 DLLEXPORT AbstractPollState* startSslConnect(ExceptionSink* xsink, QoreSSLCertificate* cert = nullptr,
173 QoreSSLPrivateKey* pkey = nullptr);
174
176
185 DLLEXPORT AbstractPollState* startSend(ExceptionSink* xsink, const char* data, size_t size);
186
188
196 DLLEXPORT AbstractPollState* startAccept(ExceptionSink* xsink);
197
199
208 DLLEXPORT AbstractPollState* startSslAccept(ExceptionSink* xsink, QoreSSLCertificate* cert = nullptr,
209 QoreSSLPrivateKey* pkey = nullptr);
210
212
220 DLLEXPORT AbstractPollState* startRecv(ExceptionSink* xsink, size_t size);
221
223
233 DLLEXPORT AbstractPollState* startRecvUntilBytes(ExceptionSink* xsink, const char* pattern, size_t size);
234
236
243 DLLEXPORT AbstractPollState* startRecvPacket(ExceptionSink* xsink);
244
245#if 0
247
254 DLLEXPORT AbstractPollState* startAccept(ExceptionSink* xsink);
255
257
264 DLLEXPORT AbstractPollState* startSslAccept(ExceptionSink* xsink, QoreSSLCertificate* cert = nullptr,
265 QoreSSLPrivateKey* pkey = nullptr);
266#endif
267
269
280 DLLEXPORT int connect(const char* name, ExceptionSink* xsink = nullptr);
281
283
295 DLLEXPORT int connect(const char* name, int timeout_ms, ExceptionSink* xsink = nullptr);
296
298
308 DLLEXPORT int connectINET(const char* host, int prt, ExceptionSink* xsink = nullptr);
309
311
325 DLLEXPORT int connectINET2(const char* name, const char* service, int family = Q_AF_UNSPEC,
326 int sock_type = Q_SOCK_STREAM, int protocol = 0, int timeout_ms = -1, ExceptionSink* xsink = nullptr);
327
329
340 DLLEXPORT int connectINET(const char* host, int prt, int timeout_ms, ExceptionSink* xsink = nullptr);
341
343
352 DLLEXPORT int connectUNIX(const char* p, ExceptionSink* xsink = nullptr);
353
355
366 DLLEXPORT int connectUNIX(const char* p, int socktype, int protocol = 0, ExceptionSink* xsink = nullptr);
367
369
388 DLLEXPORT int connectSSL(ExceptionSink* xsink, const char* name, QoreSSLCertificate* cert = nullptr,
389 QoreSSLPrivateKey* pkey = nullptr);
390
392
412 DLLEXPORT int connectSSL(ExceptionSink* xsink, const char* name, int timeout_ms, QoreSSLCertificate* cert = nullptr,
413 QoreSSLPrivateKey* pkey = nullptr);
414
416
434 DLLEXPORT int connectINETSSL(ExceptionSink* xsink, const char* host, int prt, QoreSSLCertificate* cert = nullptr,
435 QoreSSLPrivateKey* pkey = nullptr);
436
438
457 DLLEXPORT int connectINETSSL(ExceptionSink* xsink, const char* host, int prt, int timeout_ms,
458 QoreSSLCertificate* cert = nullptr, QoreSSLPrivateKey* pkey = nullptr);
459
461
479 DLLEXPORT int connectINET2SSL(ExceptionSink* xsink, const char* name, const char* service, int family,
480 int sock_type, int protocol, int timeout_ms, QoreSSLCertificate* cert = nullptr,
481 QoreSSLPrivateKey* pkey = nullptr);
482
484
501 DLLEXPORT int connectUNIXSSL(ExceptionSink* xsink, const char* p, QoreSSLCertificate* cert = nullptr,
502 QoreSSLPrivateKey* pkey = nullptr);
503
505
524 DLLEXPORT int connectUNIXSSL(ExceptionSink* xsink, const char* p, int socktype, int protocol,
525 QoreSSLCertificate* cert = nullptr, QoreSSLPrivateKey* pkey = nullptr);
526
528
534 DLLEXPORT int bind(const char* name, bool reuseaddr = false);
535
537
542 DLLEXPORT int bind(int prt, bool reuseaddr);
543
545
551 DLLEXPORT int bind(const char* iface, int prt, bool reuseaddr = false);
552
554
561 DLLEXPORT int bind(const struct sockaddr *addr, int addr_size);
562
564
572 DLLEXPORT int bind(int family, const struct sockaddr *addr, int addr_size, int socktype = Q_SOCK_STREAM,
573 int protocol = 0);
574
576
584 DLLEXPORT int bindUNIX(const char* name, ExceptionSink* xsink = nullptr);
585
587
597 DLLEXPORT int bindUNIX(const char* name, int socktype, int protocol = 0, ExceptionSink* xsink = nullptr);
598
600
613 DLLEXPORT int bindINET(const char* name, const char* service, bool reuseaddr = true, int family = Q_AF_UNSPEC,
614 int socktype = Q_SOCK_STREAM, int protocol = 0, ExceptionSink* xsink = nullptr);
615
617 DLLEXPORT int getPort();
618
620
632 DLLEXPORT QoreSocket* accept(SocketSource* source, ExceptionSink* xsink);
633
635
651 QoreSSLPrivateKey* pkey);
652
654
666 DLLEXPORT int acceptAndReplace(SocketSource* source);
667
669
681 DLLEXPORT QoreSocket* accept(int timeout_ms, ExceptionSink* xsink);
682
684
700 DLLEXPORT QoreSocket* acceptSSL(ExceptionSink* xsink, int timeout_ms, QoreSSLCertificate* cert = nullptr,
701 QoreSSLPrivateKey* pkey = nullptr);
702
704
716 DLLEXPORT int acceptAndReplace(int timeout_ms, ExceptionSink* xsink);
717
719
722 DLLEXPORT int listen();
723
725
731 DLLEXPORT int listen(int backlog);
732
734
740 DLLEXPORT int send(const char* buf, size_t size);
741
743
750 DLLEXPORT int send(const char* buf, size_t size, ExceptionSink* xsink);
751
753
761 DLLEXPORT int send(const char* buf, size_t size, int timeout_ms, ExceptionSink* xsink);
762
764
770 DLLEXPORT int send(const QoreString *msg, ExceptionSink* xsink);
771
773
780 DLLEXPORT int send(const QoreString *msg, int timeout_ms, ExceptionSink* xsink);
781
783
792 DLLEXPORT int send(const QoreStringNode& msg, int timeout_ms, ExceptionSink* xsink);
793
795
800 DLLEXPORT int send(const BinaryNode* msg);
801
803
809 DLLEXPORT int send(const BinaryNode* msg, ExceptionSink* xsink);
810
812
819 DLLEXPORT int send(const BinaryNode* msg, int timeout_ms, ExceptionSink* xsink);
820
822
828 DLLEXPORT int send(int fd, qore_offset_t size = -1);
829
831
841 DLLEXPORT int send(int fd, qore_offset_t size, int timeout_ms, ExceptionSink* xsink);
842
844
848 DLLEXPORT int sendi1(char i);
849
851
856 DLLEXPORT int sendi2(short i);
857
859
864 DLLEXPORT int sendi4(int i);
865
867
872 DLLEXPORT int sendi8(int64 i);
873
875
881 DLLEXPORT int sendi2LSB(short i);
882
884
890 DLLEXPORT int sendi4LSB(int i);
891
893
899 DLLEXPORT int sendi8LSB(int64 i);
900
902
910 DLLEXPORT int sendi1(char i, int timeout_ms, ExceptionSink* xsink);
911
913
922 DLLEXPORT int sendi2(short i, int timeout_ms, ExceptionSink* xsink);
923
925
934 DLLEXPORT int sendi4(int i, int timeout_ms, ExceptionSink* xsink);
935
937
946 DLLEXPORT int sendi8(int64 i, int timeout_ms, ExceptionSink* xsink);
947
949
959 DLLEXPORT int sendi2LSB(short i, int timeout_ms, ExceptionSink* xsink);
960
962
972 DLLEXPORT int sendi4LSB(int i, int timeout_ms, ExceptionSink* xsink);
973
975
985 DLLEXPORT int sendi8LSB(int64 i, int timeout_ms, ExceptionSink* xsink);
986
988
997 DLLEXPORT int recvi1(int timeout_ms, char* val);
998
1000
1010 DLLEXPORT int recvi2(int timeout_ms, short *val);
1011
1013
1023 DLLEXPORT int recvi4(int timeout_ms, int* val);
1024
1026
1036 DLLEXPORT int recvi8(int timeout_ms, int64 *val);
1037
1039
1050 DLLEXPORT int recvi2LSB(int timeout_ms, short *val);
1051
1053
1064 DLLEXPORT int recvi4LSB(int timeout_ms, int* val);
1065
1067
1076 DLLEXPORT int recvi8LSB(int timeout_ms, int64 *val);
1077
1079
1087 DLLEXPORT int recvu1(int timeout_ms, unsigned char* val);
1088
1090
1100 DLLEXPORT int recvu2(int timeout_ms, unsigned short *val);
1101
1103
1113 DLLEXPORT int recvu4(int timeout_ms, unsigned int* val);
1114
1116
1128 DLLEXPORT int recvu2LSB(int timeout_ms, unsigned short *val);
1129
1131
1143 DLLEXPORT int recvu4LSB(int timeout_ms, unsigned int* val);
1144
1146
1156 DLLEXPORT int64 recvi1(int timeout_ms, char* val, ExceptionSink* xsink);
1157
1159
1170 DLLEXPORT int64 recvi2(int timeout_ms, short *val, ExceptionSink* xsink);
1171
1173
1185 DLLEXPORT int64 recvi4(int timeout_ms, int* val, ExceptionSink* xsink);
1186
1188
1199 DLLEXPORT int64 recvi8(int timeout_ms, int64 *val, ExceptionSink* xsink);
1200
1202
1215 DLLEXPORT int64 recvi2LSB(int timeout_ms, short *val, ExceptionSink* xsink);
1216
1218
1231 DLLEXPORT int64 recvi4LSB(int timeout_ms, int* val, ExceptionSink* xsink);
1232
1234
1245 DLLEXPORT int64 recvi8LSB(int timeout_ms, int64 *val, ExceptionSink* xsink);
1246
1248
1258 DLLEXPORT int64 recvu1(int timeout_ms, unsigned char* val, ExceptionSink* xsink);
1259
1261
1273 DLLEXPORT int64 recvu2(int timeout_ms, unsigned short *val, ExceptionSink* xsink);
1274
1276
1288 DLLEXPORT int64 recvu4(int timeout_ms, unsigned int* val, ExceptionSink* xsink);
1289
1291
1305 DLLEXPORT int64 recvu2LSB(int timeout_ms, unsigned short *val, ExceptionSink* xsink);
1306
1308
1322 DLLEXPORT int64 recvu4LSB(int timeout_ms, unsigned int* val, ExceptionSink* xsink);
1323
1325
1334 DLLEXPORT QoreStringNode* recv(qore_offset_t bufsize, int timeout_ms, int* prc);
1335
1337
1346 DLLEXPORT QoreStringNode* recv(qore_offset_t bufsize, int timeout_ms, ExceptionSink* xsink);
1347
1349
1356 DLLEXPORT BinaryNode* recvBinary(qore_offset_t bufsize, int timeout_ms, int* prc);
1357
1359
1366 DLLEXPORT BinaryNode* recvBinary(qore_offset_t bufsize, int timeout_ms, ExceptionSink* xsink);
1367
1369
1380 DLLEXPORT QoreStringNode* recv(int timeout_ms, int* prc);
1381
1383
1394 DLLEXPORT QoreStringNode* recv(int timeout_ms, ExceptionSink* xsink);
1395
1397
1407 DLLEXPORT BinaryNode* recvBinary(int timeout_ms, int* prc);
1408
1410
1420 DLLEXPORT BinaryNode* recvBinary(int timeout_ms, ExceptionSink* xsink);
1421
1423
1433 DLLEXPORT int recv(int fd, qore_offset_t size, int timeout_ms);
1434
1436
1449 DLLEXPORT int recv(int fd, qore_offset_t size, int timeout_ms, ExceptionSink* xsink);
1450
1452
1463 DLLEXPORT int sendHTTPMessage(const char* method, const char* path, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source = QORE_SOURCE_SOCKET);
1464
1466
1478 DLLEXPORT int sendHTTPMessage(QoreHashNode* info, const char* method, const char* path, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source = QORE_SOURCE_SOCKET);
1479
1481
1495 DLLEXPORT int sendHTTPMessage(ExceptionSink* xsink, QoreHashNode* info, const char* method, const char* path, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source = QORE_SOURCE_SOCKET);
1496
1498
1513 DLLEXPORT int sendHTTPMessage(ExceptionSink* xsink, QoreHashNode* info, const char* method, const char* path, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source, int timeout_ms);
1514
1516
1530 DLLEXPORT int sendHTTPMessageWithCallback(ExceptionSink* xsink, QoreHashNode* info, const char* method, const char* path, const char* http_version, const QoreHashNode* headers, const ResolvedCallReferenceNode& send_callback, int source, int timeout_ms);
1531
1533
1545 DLLEXPORT int sendHTTPResponse(int code, const char* desc, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source = QORE_SOURCE_SOCKET);
1546
1548
1561 DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, int code, const char* desc, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source = QORE_SOURCE_SOCKET);
1562
1564
1578 DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, int code, const char* desc, const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source, int timeout_ms);
1579
1581
1598 DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, QoreHashNode* info, int code, const char* desc,
1599 const char* http_version, const QoreHashNode* headers, const void* data, size_t size, int source,
1600 int timeout_ms);
1601
1603
1612 DLLEXPORT AbstractQoreNode* readHTTPHeader(int timeout_ms, int* prc, int source = QORE_SOURCE_SOCKET);
1613
1615
1625 DLLEXPORT AbstractQoreNode* readHTTPHeader(QoreHashNode* info, int timeout_ms, int* prc, int source = QORE_SOURCE_SOCKET);
1626
1628
1639 DLLEXPORT QoreHashNode* readHTTPHeader(ExceptionSink* xsink, QoreHashNode* info, int timeout_ms, int source = QORE_SOURCE_SOCKET);
1640
1642
1652 DLLEXPORT QoreStringNode* readHTTPHeaderString(ExceptionSink* xsink, int timeout_ms, int source = QORE_SOURCE_SOCKET);
1653
1655
1667 DLLEXPORT QoreHashNode* readHTTPChunkedBodyBinary(int timeout_ms, ExceptionSink* xsink, int source = QORE_SOURCE_SOCKET);
1668
1670
1682 DLLEXPORT QoreHashNode* readHTTPChunkedBody(int timeout_ms, ExceptionSink* xsink, int source = QORE_SOURCE_SOCKET);
1683
1685
1698 DLLEXPORT QoreHashNode* readHttpChunk(int timeout, ExceptionSink* xsink);
1699
1701
1712 DLLEXPORT QoreHashNode* readServerSentEvent(ExceptionSink* xsink, const QoreStringNode* content_encoding,
1713 int timeout_ms);
1714
1716
1721 DLLEXPORT static QoreHashNode* parseServerSentEvent(ExceptionSink* xsink, const QoreString& buf);
1722
1724 DLLEXPORT int setSendTimeout(int ms);
1725
1727 DLLEXPORT int setRecvTimeout(int ms);
1728
1730 DLLEXPORT int getSendTimeout() const;
1731
1733 DLLEXPORT int getRecvTimeout() const;
1734
1736
1747 DLLEXPORT bool isDataAvailable(int timeout_ms = 0) const;
1748
1750
1764 DLLEXPORT bool isDataAvailable(ExceptionSink* xsink, int timeout_ms = 0) const;
1765
1767
1779 DLLEXPORT int asyncIoWait(int timeout_ms, bool read, bool write) const;
1780
1782
1786 DLLEXPORT int close();
1787
1789
1798 DLLEXPORT int shutdown();
1799
1801
1807 DLLEXPORT int shutdownSSL(ExceptionSink* xsink);
1808
1810
1812 DLLEXPORT int getSocket() const;
1813
1815
1817 DLLEXPORT const QoreEncoding *getEncoding() const;
1818
1820
1822 DLLEXPORT void setEncoding(const QoreEncoding *id);
1823
1825
1827 DLLEXPORT bool isOpen() const;
1828
1830
1832 DLLEXPORT const char* getSSLCipherName() const;
1833
1835
1837 DLLEXPORT const char* getSSLCipherVersion() const;
1838
1840
1842 DLLEXPORT bool isSecure() const;
1843
1845 DLLEXPORT long verifyPeerCertificate() const;
1846
1848
1857 DLLEXPORT int upgradeServerToSSL(ExceptionSink* xsink, int timeout_ms = -1, QoreSSLCertificate* cert = nullptr,
1858 QoreSSLPrivateKey* pkey = nullptr);
1859
1861
1870 DLLEXPORT int upgradeClientToSSL(ExceptionSink* xsink, int timeout_ms = -1, QoreSSLCertificate* cert = nullptr,
1871 QoreSSLPrivateKey* pkey = nullptr);
1872
1874
1883 DLLEXPORT bool isWriteFinished(int timeout_ms = 0) const;
1884
1886
1896 DLLEXPORT bool isWriteFinished(ExceptionSink* xsink, int timeout_ms = 0) const;
1897
1899
1911 DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink) const;
1912
1914
1928 DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink, bool host_lookup) const;
1929
1931
1944 DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink) const;
1945
1947
1961 DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink, bool host_lookup) const;
1962
1963 DLLEXPORT void clearWarningQueue(ExceptionSink* xsink);
1964 DLLEXPORT void setWarningQueue(ExceptionSink* xsink, int64 warning_ms, int64 warning_bs, Queue* wq, QoreValue arg, int64 min_ms = 1000);
1965 DLLEXPORT QoreHashNode* getUsageInfo() const;
1966 DLLEXPORT void clearStats();
1967
1969 DLLEXPORT void cleanup(ExceptionSink* xsink);
1970
1972 DLLEXPORT bool pendingHttpChunkedBody() const;
1973
1975
1981 DLLEXPORT void setSslVerifyMode(int mode);
1982
1984
1988 DLLEXPORT int getSslVerifyMode() const;
1989
1991
1995 DLLEXPORT void acceptAllCertificates(bool accept_all = true);
1996
1998
2002 DLLEXPORT bool getAcceptAllCertificates() const;
2003
2005
2013 DLLEXPORT bool captureRemoteCertificates(bool set);
2014
2016
2023
2025
2029 DLLEXPORT int64 getConnectionId() const;
2030
2031 DLLLOCAL static void doException(int rc, const char* meth, int timeout_ms, ExceptionSink* xsink);
2032
2034 DLLLOCAL void setEventQueue(ExceptionSink* xsink, Queue* q, QoreValue arg, bool with_data);
2035
2037 DLLLOCAL Queue* getQueue();
2038
2040 DLLLOCAL int64 getObjectIDForEvents() const;
2041
2042 DLLLOCAL int setNoDelay(int nodelay);
2043 DLLLOCAL int getNoDelay() const;
2044
2046 DLLLOCAL void setAccept(QoreObject* o);
2047
2048private:
2050 hashdecl qore_socket_private *priv;
2051
2053 DLLLOCAL QoreSocket(int n_sock, int n_sfamily, int n_stype, int s_prot, const QoreEncoding* csid);
2054
2055 DLLLOCAL static void convertHeaderToHash(QoreHashNode* h, char* p);
2056
2057 DLLLOCAL QoreSocket(const QoreSocket&) = delete;
2058 DLLLOCAL QoreSocket& operator=(const QoreSocket&) = delete;
2059};
2060
2061class QoreSocketTimeoutHelper {
2062protected:
2063 class PrivateQoreSocketTimeoutHelper* priv;
2064public:
2065 DLLEXPORT QoreSocketTimeoutHelper(QoreSocket& s, const char* op);
2066 DLLEXPORT ~QoreSocketTimeoutHelper();
2067};
2068
2069class QoreSocketThroughputHelper {
2070protected:
2071 class PrivateQoreSocketThroughputHelper* priv;
2072public:
2073 DLLEXPORT QoreSocketThroughputHelper(QoreSocket& s, bool snd);
2074 DLLEXPORT ~QoreSocketThroughputHelper();
2075 DLLEXPORT void finalize(int64 bytes);
2076};
2077
2078#endif // _QORE_QORESOCKET_H
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
defines string encoding functions in Qore
Definition QoreEncoding.h:83
provides thread-safe access to FTP servers through Qore data structures
Definition QoreFtpClient.h:71
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
DLLEXPORT bool captureRemoteCertificates(bool set)
sets the capture SSL certificate flag
DLLEXPORT int send(int fd, qore_offset_t size, int timeout_ms, ExceptionSink *xsink)
sends untranslated data from an open file descriptor
DLLEXPORT int getRecvTimeout() const
get recv timeout in milliseconds
DLLEXPORT int recvi2LSB(int timeout_ms, short *val)
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the soc...
DLLEXPORT int send(const char *buf, size_t size)
sends binary data on a connected socket
DLLEXPORT int connectSSL(ExceptionSink *xsink, const char *name, int timeout_ms, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptio...
DLLEXPORT QoreStringNode * recv(qore_offset_t bufsize, int timeout_ms, int *prc)
receive a certain number of bytes with a timeout value and return a QoreStringNode,...
DLLEXPORT int recvi8LSB(int timeout_ms, int64 *val)
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the so...
DLLEXPORT AbstractPollState * startRecvUntilBytes(ExceptionSink *xsink, const char *pattern, size_t size)
Starts a non-blocking receive operation on a connected socket.
DLLEXPORT int connectINET(const char *host, int prt, int timeout_ms, ExceptionSink *xsink=nullptr)
connects to an INET socket by hostname and port number and returns a status code, Qore-language excep...
DLLEXPORT AbstractPollState * startAccept(ExceptionSink *xsink)
Starts a non-blocking accept operation to a socket and returns a poll state object.
DLLEXPORT void setSslVerifyMode(int mode)
sets the SSL verification mode
DLLEXPORT int64 recvu1(int timeout_ms, unsigned char *val, ExceptionSink *xsink)
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an...
DLLEXPORT AbstractPollState * startSslAccept(ExceptionSink *xsink, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
Starts a non-blocking upgrade to an SSL connection on a connected server connection.
DLLEXPORT int connectINET2SSL(ExceptionSink *xsink, const char *name, const char *service, int family, int sock_type, int protocol, int timeout_ms, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to an INET or INET6 socket by hostname and port number or service name and returns a status ...
DLLEXPORT int send(const BinaryNode *msg, ExceptionSink *xsink)
sends binary data on a connected socket
static DLLEXPORT QoreHashNode * parseServerSentEvent(ExceptionSink *xsink, const QoreString &buf)
Parse a string as a Server Sent Event (SSE) string.
DLLEXPORT QoreHashNode * getPeerInfo(ExceptionSink *xsink, bool host_lookup) const
returns peer information for a connected socket
DLLEXPORT void setEncoding(const QoreEncoding *id)
sets the character encoding for strings sent and received with this socket
DLLEXPORT int sendHTTPResponse(ExceptionSink *xsink, QoreHashNode *info, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms)
send an HTTP response message on the socket
DLLEXPORT int setSendTimeout(int ms)
set send timeout in milliseconds
DLLEXPORT AbstractPollState * startSend(ExceptionSink *xsink, const char *data, size_t size)
Starts a non-blocking send operation on a connected socket.
DLLEXPORT int sendHTTPMessage(QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP request message on the socket
DLLEXPORT bool pendingHttpChunkedBody() const
returns true if a HTTP header was read indicating chunked transfer encoding, but no chunked body has ...
DLLEXPORT bool isDataAvailable(ExceptionSink *xsink, int timeout_ms=0) const
returns true if data is available on the socket in the timeout period in milliseconds
DLLEXPORT bool getAcceptAllCertificates() const
returns the current value of the "accept all certificates" flag
DLLEXPORT int connectINET(const char *host, int prt, ExceptionSink *xsink=nullptr)
connects to an INET socket by hostname and port number and returns a status code, Qore-language excep...
DLLLOCAL Queue * getQueue()
returns the event queue (not part of the library's public API)
DLLEXPORT int close()
closes the socket
DLLEXPORT int recvu4(int timeout_ms, unsigned int *val)
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from...
DLLEXPORT long verifyPeerCertificate() const
returns the peer certificate verification code if an SSL connection is in progress
DLLEXPORT int64 recvi2LSB(int timeout_ms, short *val, ExceptionSink *xsink)
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the soc...
DLLEXPORT QoreSocket()
creates an empty, unconnected socket
DLLEXPORT int asyncIoWait(int timeout_ms, bool read, bool write) const
returns 1 if the event was satisfied in the timeout period, 0 if not (= timeout), or -1 in case of an...
DLLEXPORT int sendHTTPMessageWithCallback(ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const ResolvedCallReferenceNode &send_callback, int source, int timeout_ms)
send an HTTP request message on the socket with a timeout value with a chunked message body using a c...
DLLEXPORT int64 recvi8(int timeout_ms, int64 *val, ExceptionSink *xsink)
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from ...
DLLEXPORT int getPort()
returns the TCP port number, also assigns the interal port number if it must be discovered
DLLEXPORT int acceptAndReplace(SocketSource *source)
accepts a new connection on a listening socket and replaces the current socket with the new connectio...
DLLEXPORT AbstractPollState * startRecv(ExceptionSink *xsink, size_t size)
Starts a non-blocking receive operation on a connected socket.
DLLEXPORT QoreSocket * accept(SocketSource *source, ExceptionSink *xsink)
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connec...
DLLEXPORT int connectUNIXSSL(ExceptionSink *xsink, const char *p, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code,...
DLLEXPORT bool isSecure() const
returns true if an SSL connection is active
DLLLOCAL int64 getObjectIDForEvents() const
returns a unique ID for the socket to be used in event messages
DLLEXPORT AbstractPollState * startRecvPacket(ExceptionSink *xsink)
Starts a non-blocking receive packet operation on a connected socket.
DLLEXPORT int acceptAndReplace(int timeout_ms, ExceptionSink *xsink)
accepts a new connection on a listening socket and replaces the current socket with the new connectio...
DLLEXPORT int sendi2LSB(short i)
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
DLLEXPORT int connect(const char *name, ExceptionSink *xsink=nullptr)
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of an...
DLLEXPORT int send(const BinaryNode *msg)
sends binary data on a connected socket
DLLEXPORT void acceptAllCertificates(bool accept_all=true)
with peer verification enabled, all certificates are accepted regardless of the validity of the Certi...
DLLEXPORT QoreStringNode * recv(int timeout_ms, ExceptionSink *xsink)
receive with a timeout value and return a QoreStringNode, caller owns the reference count returned
DLLEXPORT int sendi1(char i)
sends a 1-byte binary integer data to a connected socket
DLLEXPORT int64 recvu4LSB(int timeout_ms, unsigned int *val, ExceptionSink *xsink)
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the s...
DLLEXPORT QoreSocket * acceptSSL(ExceptionSink *xsink, int timeout_ms, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreS...
DLLEXPORT bool isDataAvailable(int timeout_ms=0) const
returns true if data is available on the socket in the timeout period in milliseconds
DLLEXPORT int sendi8LSB(int64 i, int timeout_ms, ExceptionSink *xsink)
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format th...
DLLLOCAL void setEventQueue(ExceptionSink *xsink, Queue *q, QoreValue arg, bool with_data)
sets the event queue (not part of the library's pubilc API), must be already referenced before call
DLLEXPORT int64 recvi8LSB(int timeout_ms, int64 *val, ExceptionSink *xsink)
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the so...
DLLEXPORT bool isWriteFinished(int timeout_ms=0) const
returns true if all write data has been written within the timeout period in milliseconds
DLLEXPORT int sendHTTPMessage(ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms)
send an HTTP request message on the socket with a timeout value
DLLEXPORT int getSslVerifyMode() const
returns the SSL verification mode
DLLEXPORT int shutdownSSL(ExceptionSink *xsink)
shuts down an active SSL connection
DLLEXPORT int recvu2LSB(int timeout_ms, unsigned short *val)
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the s...
DLLEXPORT BinaryNode * recvBinary(int timeout_ms, ExceptionSink *xsink)
receive with a timeout value and return a BinaryNode, caller owns the reference count returned
DLLEXPORT const QoreEncoding * getEncoding() const
returns the character encoding associated with this socket
DLLEXPORT int recv(int fd, qore_offset_t size, int timeout_ms, ExceptionSink *xsink)
receive data on the socket and write it to a file descriptor
DLLEXPORT int upgradeServerToSSL(ExceptionSink *xsink, int timeout_ms=-1, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
negotiates an SSL connection from the client side
DLLEXPORT void cleanup(ExceptionSink *xsink)
posts deleted message and removes any event queue
DLLEXPORT QoreStringNode * recv(qore_offset_t bufsize, int timeout_ms, ExceptionSink *xsink)
receive a certain number of bytes with a timeout value and return a QoreStringNode,...
DLLEXPORT int send(const BinaryNode *msg, int timeout_ms, ExceptionSink *xsink)
sends binary data on a connected socket
DLLEXPORT int bind(const char *name, bool reuseaddr=false)
binds to a UNIX domain socket or INET interface:port using TCP and returns a status code
DLLEXPORT int recvi1(int timeout_ms, char *val)
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an o...
DLLEXPORT int bind(const hashdecl sockaddr *addr, int addr_size)
binds an INET TCP socket to a specific socket address - do not use, deprecated, use bind(int family,...
DLLEXPORT bool isWriteFinished(ExceptionSink *xsink, int timeout_ms=0) const
returns true if all write data has been written within the timeout period in milliseconds
DLLEXPORT int sendi8(int64 i)
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian,...
DLLEXPORT QoreSocket * acceptSSL(ExceptionSink *xsink, SocketSource *source, QoreSSLCertificate *cert, QoreSSLPrivateKey *pkey)
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreS...
DLLEXPORT QoreHashNode * getPeerInfo(ExceptionSink *xsink) const
returns peer information for a connected socket
DLLEXPORT QoreHashNode * readHTTPChunkedBody(int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET)
receive a string message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count ...
DLLEXPORT int getSocket() const
returns the file descriptor associated with this socket
DLLEXPORT int connectUNIX(const char *p, ExceptionSink *xsink=nullptr)
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in th...
DLLEXPORT BinaryNode * recvBinary(int timeout_ms, int *prc)
receive with a timeout value and return a BinaryNode, caller owns the reference count returned
DLLEXPORT int listen(int backlog)
sets an open socket to the listening state
DLLEXPORT AbstractQoreNode * readHTTPHeader(QoreHashNode *info, int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET)
read and parse HTTP header, caller owns AbstractQoreNode reference count returned
DLLLOCAL void setAccept(QoreObject *o)
sets backwards-compatible members on accept in a new object - will be removed in a future version of ...
DLLEXPORT QoreStringNode * recv(int timeout_ms, int *prc)
receive with a timeout value and return a QoreStringNode, caller owns the reference count returned
DLLEXPORT QoreStringNode * readHTTPHeaderString(ExceptionSink *xsink, int timeout_ms, int source=QORE_SOURCE_SOCKET)
read a HTTP header, caller owns QoreStringNode reference count returned
DLLEXPORT int connectINETSSL(ExceptionSink *xsink, const char *host, int prt, int timeout_ms, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to an INET socket by hostname and port number, negotiates an SSL connection,...
DLLEXPORT int bind(const char *iface, int prt, bool reuseaddr=false)
binds to a TCP INET (ipv4 only) port on the given interface and returns a status code
DLLEXPORT int bindUNIX(const char *name, int socktype, int protocol=0, ExceptionSink *xsink=nullptr)
binds to a UNIX domain socket and returns a status code
DLLEXPORT int recvi4LSB(int timeout_ms, int *val)
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the soc...
DLLEXPORT int recvu2(int timeout_ms, unsigned short *val)
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from...
DLLEXPORT QoreHashNode * getSocketInfo(ExceptionSink *xsink) const
returns information for the current socket; the socket must be open
DLLEXPORT int sendHTTPResponse(ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP response message on the socket
DLLEXPORT bool isOpen() const
returns true if the socket is open
DLLEXPORT int connectINET2(const char *name, const char *service, int family=Q_AF_UNSPEC, int sock_type=Q_SOCK_STREAM, int protocol=0, int timeout_ms=-1, ExceptionSink *xsink=nullptr)
connects to an INET or INET6 socket by hostname and port number or service name and returns a status ...
DLLEXPORT int recv(int fd, qore_offset_t size, int timeout_ms)
receive data on the socket and write it to a file descriptor
DLLEXPORT int sendi4(int i, int timeout_ms, ExceptionSink *xsink)
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian,...
DLLEXPORT int64 recvi1(int timeout_ms, char *val, ExceptionSink *xsink)
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an o...
DLLEXPORT int sendi4(int i)
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian,...
DLLEXPORT int send(const char *buf, size_t size, int timeout_ms, ExceptionSink *xsink)
sends binary data on a connected socket
DLLEXPORT int connectINETSSL(ExceptionSink *xsink, const char *host, int prt, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to an INET socket by hostname and port number, negotiates an SSL connection,...
DLLEXPORT int sendHTTPMessage(const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP request message on the socket
DLLEXPORT int sendi2(short i, int timeout_ms, ExceptionSink *xsink)
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian,...
DLLEXPORT AbstractPollState * startSslConnect(ExceptionSink *xsink, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
Starts a non-blocking upgrade to an SSL connection on a connected client connection.
DLLEXPORT int connectUNIXSSL(ExceptionSink *xsink, const char *p, int socktype, int protocol, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code,...
DLLEXPORT int recvi8(int timeout_ms, int64 *val)
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from ...
DLLEXPORT const char * getSSLCipherName() const
returns the name of the SSL Cipher for the currently-connected control connection,...
DLLEXPORT QoreHashNode * readHttpChunk(int timeout, ExceptionSink *xsink)
receive a single HTTP chunk
DLLEXPORT QoreHashNode * readServerSentEvent(ExceptionSink *xsink, const QoreStringNode *content_encoding, int timeout_ms)
Read and return a Server Sent Event message.
DLLEXPORT QoreSocket * accept(int timeout_ms, ExceptionSink *xsink)
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connec...
DLLEXPORT int connectUNIX(const char *p, int socktype, int protocol=0, ExceptionSink *xsink=nullptr)
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in th...
DLLEXPORT int send(int fd, qore_offset_t size=-1)
sends untranslated data from an open file descriptor
DLLEXPORT int recvu4LSB(int timeout_ms, unsigned int *val)
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the s...
DLLEXPORT int send(const QoreString *msg, ExceptionSink *xsink)
sends string data on a connected socket, converts the string encoding to the socket's encoding if nec...
DLLEXPORT int64 recvi2(int timeout_ms, short *val, ExceptionSink *xsink)
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from t...
DLLEXPORT int upgradeClientToSSL(ExceptionSink *xsink, int timeout_ms=-1, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
negotiates an SSL connection from the client side
DLLEXPORT int send(const QoreString *msg, int timeout_ms, ExceptionSink *xsink)
sends string data on a connected socket, converts the string encoding to the socket's encoding if nec...
DLLEXPORT int64 recvu2(int timeout_ms, unsigned short *val, ExceptionSink *xsink)
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from...
DLLEXPORT int recvu1(int timeout_ms, unsigned char *val)
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an...
DLLEXPORT int listen()
sets an open socket to the listening state
DLLEXPORT int recvi4(int timeout_ms, int *val)
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from t...
DLLEXPORT AbstractQoreNode * readHTTPHeader(int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET)
read and parse HTTP header, caller owns AbstractQoreNode reference count returned
DLLEXPORT AbstractPollState * startConnect(ExceptionSink *xsink, const char *name)
Starts a non-blocking connection to a socket and returns a poll state object.
DLLEXPORT int bindINET(const char *name, const char *service, bool reuseaddr=true, int family=Q_AF_UNSPEC, int socktype=Q_SOCK_STREAM, int protocol=0, ExceptionSink *xsink=nullptr)
binds an INET or INET6 TCP socket to a specific socket address
DLLEXPORT int setRecvTimeout(int ms)
set recv timeout in milliseconds
DLLEXPORT int sendi8(int64 i, int timeout_ms, ExceptionSink *xsink)
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian,...
DLLEXPORT const char * getSSLCipherVersion() const
returns the version string of the SSL Cipher for the currently-connected control connection,...
DLLEXPORT int getSendTimeout() const
get send timeout in milliseconds
DLLEXPORT BinaryNode * recvBinary(qore_offset_t bufsize, int timeout_ms, ExceptionSink *xsink)
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the refer...
DLLEXPORT int bind(int prt, bool reuseaddr)
binds to a TCP INET (ipv4 only) port on all interfaces and returns a status code
DLLEXPORT int sendHTTPResponse(ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms)
send an HTTP response message on the socket
DLLEXPORT int64 recvu4(int timeout_ms, unsigned int *val, ExceptionSink *xsink)
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from...
DLLEXPORT int send(const QoreStringNode &msg, int timeout_ms, ExceptionSink *xsink)
sends string data on a connected socket, converts the string encoding to the socket's encoding if nec...
DLLEXPORT int sendHTTPResponse(int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP response message on the socket
DLLEXPORT QoreHashNode * readHTTPHeader(ExceptionSink *xsink, QoreHashNode *info, int timeout_ms, int source=QORE_SOURCE_SOCKET)
read and parse HTTP header, caller owns QoreHashNode reference count returned
DLLEXPORT int sendi4LSB(int i, int timeout_ms, ExceptionSink *xsink)
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
DLLEXPORT int sendHTTPMessage(ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP request message on the socket
DLLEXPORT int sendi1(char i, int timeout_ms, ExceptionSink *xsink)
sends a 1-byte binary integer data to a connected socket
DLLEXPORT int64 recvu2LSB(int timeout_ms, unsigned short *val, ExceptionSink *xsink)
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the s...
DLLEXPORT ~QoreSocket()
disconnects if necessary, frees all data, and destroys the socket
DLLEXPORT QoreObject * getRemoteCertificate() const
returns a remote certificate if available
DLLEXPORT int sendi2(short i)
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian,...
DLLEXPORT int64 getConnectionId() const
returns a connection ID to help identifying when new connections are made
DLLEXPORT int bindUNIX(const char *name, ExceptionSink *xsink=nullptr)
binds to a UNIX domain socket and returns a status code
DLLEXPORT int connectSSL(ExceptionSink *xsink, const char *name, QoreSSLCertificate *cert=nullptr, QoreSSLPrivateKey *pkey=nullptr)
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptio...
DLLEXPORT BinaryNode * recvBinary(qore_offset_t bufsize, int timeout_ms, int *prc)
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the refer...
DLLEXPORT int bind(int family, const hashdecl sockaddr *addr, int addr_size, int socktype=Q_SOCK_STREAM, int protocol=0)
binds an INET or INET6 TCP socket to a specific socket address
DLLEXPORT int sendi4LSB(int i)
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
DLLEXPORT int shutdown()
calls shutdown on the socket
DLLEXPORT int sendi8LSB(int64 i)
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format th...
DLLEXPORT int64 recvi4LSB(int timeout_ms, int *val, ExceptionSink *xsink)
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the soc...
DLLEXPORT int64 recvi4(int timeout_ms, int *val, ExceptionSink *xsink)
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from t...
DLLEXPORT QoreHashNode * getSocketInfo(ExceptionSink *xsink, bool host_lookup) const
returns information for the current socket; the socket must be open
DLLEXPORT int send(const char *buf, size_t size, ExceptionSink *xsink)
sends binary data on a connected socket
DLLEXPORT int sendi2LSB(short i, int timeout_ms, ExceptionSink *xsink)
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
DLLEXPORT QoreHashNode * readHTTPChunkedBodyBinary(int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET)
receive a binary message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count ...
DLLEXPORT int connect(const char *name, int timeout_ms, ExceptionSink *xsink=nullptr)
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of an...
DLLEXPORT int recvi2(int timeout_ms, short *val)
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from t...
Qore's string type supported by the QoreEncoding class.
Definition QoreString.h:93
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
DLLEXPORT const char * getAddress() const
returns the host address string as a C string
DLLEXPORT ~SocketSource()
destroys the object and frees all memory
DLLEXPORT SocketSource()
creates an empty object
DLLEXPORT const char * getHostName() const
returns the hostname string as a C string
DLLEXPORT QoreStringNode * takeHostName()
returns the hostname string field and leaves the object's hostname field empty; the caller owns the Q...
DLLEXPORT QoreStringNode * takeAddress()
returns the host address string field and leaves the object's host address field empty; the caller ow...
#define Q_AF_UNSPEC
cross-platform define for AF_UNSPEC
Definition common.h:64
#define Q_SOCK_STREAM
platform-independent define for SOCK_STREAM
Definition common.h:73
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