Qore Programming Language 0.8.10

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 - 2014 David Nichols
10
11 will unlink (delete) UNIX domain socket files when closed
12
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 2.1 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27
28 #ifndef _QORE_QORESOCKET_H
29
30 #define _QORE_QORESOCKET_H
31
32 #include <qore/Qore.h>
33
34 #include <sys/types.h>
35 #include <unistd.h>
36 #include <strings.h>
37 #include <string.h>
38 #include <stdlib.h>
39 #include <ctype.h>
40 #include <unistd.h>
41
42 #include <openssl/ssl.h>
43 #include <openssl/err.h>
44
45 #define QSE_MISC_ERR 0
46 #define QSE_RECV_ERR -1
47 #define QSE_NOT_OPEN -2
48 #define QSE_TIMEOUT -3
49 #define QSE_SSL_ERR -4
50 #define QSE_IN_OP -5
51
52 class Queue;
53
55
62 class SocketSource {
63 friend struct qore_socket_private;
64
65 private:
66 struct qore_socketsource_private *priv; // private implementation
67
69 DLLLOCAL SocketSource(const SocketSource&);
70
72 DLLLOCAL SocketSource& operator=(const SocketSource&);
73
74 public:
76 DLLEXPORT SocketSource();
77
79 DLLEXPORT ~SocketSource();
80
82
84 DLLEXPORT QoreStringNode *takeAddress();
85
87
89 DLLEXPORT QoreStringNode *takeHostName();
90
92
94 DLLEXPORT const char *getAddress() const;
95
97
99 DLLEXPORT const char *getHostName() const;
100
101 DLLLOCAL void setAll(QoreObject *o, ExceptionSink* xsink);
102 };
103
105
115 class QoreSocket {
116 friend struct qore_socket_private;
117 friend struct qore_httpclient_priv;
118 friend class QoreSocketObject;
119
120 private:
122 struct qore_socket_private *priv;
123
125 DLLLOCAL QoreSocket(int n_sock, int n_sfamily, int n_stype, int s_prot, const QoreEncoding *csid);
126
127 DLLLOCAL static void convertHeaderToHash(QoreHashNode *h, char *p);
128
130 DLLLOCAL QoreSocket(const QoreSocket&);
131
133 DLLLOCAL QoreSocket& operator=(const QoreSocket&);
134
135 public:
137 DLLEXPORT QoreSocket();
138
140 DLLEXPORT ~QoreSocket();
141
143
154 DLLEXPORT int connect(const char *name, ExceptionSink* xsink = 0);
155
157
169 DLLEXPORT int connect(const char *name, int timeout_ms, ExceptionSink* xsink = 0);
170
172
182 DLLEXPORT int connectINET(const char *host, int prt, ExceptionSink* xsink = 0);
183
185
199 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 = 0);
200
202
213 DLLEXPORT int connectINET(const char *host, int prt, int timeout_ms, ExceptionSink* xsink = 0);
214
216
225 DLLEXPORT int connectUNIX(const char *p, ExceptionSink* xsink = 0);
226
228
239 DLLEXPORT int connectUNIX(const char *p, int socktype, int protocol = 0, ExceptionSink* xsink = 0);
240
242
257 DLLEXPORT int connectSSL(const char *name, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
258
260
276 DLLEXPORT int connectSSL(const char *name, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
277
279
293 DLLEXPORT int connectINETSSL(const char *host, int prt, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
294
296
311 DLLEXPORT int connectINETSSL(const char *host, int prt, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
312
314
330 DLLEXPORT int connectINET2SSL(const char *name, const char *service, int family, int sock_type, int protocol, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink = 0);
331
333
346 DLLEXPORT int connectUNIXSSL(const char *p, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
347
349
364 DLLEXPORT int connectUNIXSSL(const char *p, int socktype, int protocol, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
365
367
373 DLLEXPORT int bind(const char *name, bool reuseaddr = false);
374
376
381 DLLEXPORT int bind(int prt, bool reuseaddr);
382
384
390 DLLEXPORT int bind(const char *iface, int prt, bool reuseaddr = false);
391
393
400 DLLEXPORT int bind(const struct sockaddr *addr, int addr_size);
401
403
411 DLLEXPORT int bind(int family, const struct sockaddr *addr, int addr_size, int socktype = Q_SOCK_STREAM, int protocol = 0);
412
414
422 DLLEXPORT int bindUNIX(const char *name, ExceptionSink* xsink = 0);
423
425
435 DLLEXPORT int bindUNIX(const char *name, int socktype, int protocol = 0, ExceptionSink* xsink = 0);
436
438
450 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 = 0);
451
453 DLLEXPORT int getPort();
454
456
468 DLLEXPORT QoreSocket *accept(SocketSource *source, ExceptionSink* xsink);
469
471
486 DLLEXPORT QoreSocket *acceptSSL(SocketSource *source, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
487
489
501 DLLEXPORT int acceptAndReplace(SocketSource *source);
502
504
515 DLLEXPORT QoreSocket *accept(int timeout_ms, ExceptionSink* xsink);
516
518
530 DLLEXPORT QoreSocket *acceptSSL(int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
531
533
544 DLLEXPORT int acceptAndReplace(int timeout_ms, ExceptionSink* xsink);
545
547
550 DLLEXPORT int listen();
551
553
559 DLLEXPORT int listen(int backlog);
560
562
568 DLLEXPORT int send(const char *buf, qore_size_t size);
569
571
578 DLLEXPORT int send(const char *buf, qore_size_t size, ExceptionSink* xsink);
579
581
589 DLLEXPORT int send(const char *buf, qore_size_t size, int timeout_ms, ExceptionSink* xsink);
590
592
598 DLLEXPORT int send(const QoreString *msg, ExceptionSink* xsink);
599
601
608 DLLEXPORT int send(const QoreString *msg, int timeout_ms, ExceptionSink* xsink);
609
611
616 DLLEXPORT int send(const BinaryNode *msg);
617
619
625 DLLEXPORT int send(const BinaryNode *msg, ExceptionSink* xsink);
626
628
635 DLLEXPORT int send(const BinaryNode *msg, int timeout_ms, ExceptionSink* xsink);
636
638
644 DLLEXPORT int send(int fd, qore_offset_t size = -1);
645
647
651 DLLEXPORT int sendi1(char i);
652
654
659 DLLEXPORT int sendi2(short i);
660
662
667 DLLEXPORT int sendi4(int i);
668
670
675 DLLEXPORT int sendi8(int64 i);
676
678
684 DLLEXPORT int sendi2LSB(short i);
685
687
693 DLLEXPORT int sendi4LSB(int i);
694
696
702 DLLEXPORT int sendi8LSB(int64 i);
703
705
713 DLLEXPORT int sendi1(char i, int timeout_ms, ExceptionSink* xsink);
714
716
725 DLLEXPORT int sendi2(short i, int timeout_ms, ExceptionSink* xsink);
726
728
737 DLLEXPORT int sendi4(int i, int timeout_ms, ExceptionSink* xsink);
738
740
749 DLLEXPORT int sendi8(int64 i, int timeout_ms, ExceptionSink* xsink);
750
752
762 DLLEXPORT int sendi2LSB(short i, int timeout_ms, ExceptionSink* xsink);
763
765
775 DLLEXPORT int sendi4LSB(int i, int timeout_ms, ExceptionSink* xsink);
776
778
788 DLLEXPORT int sendi8LSB(int64 i, int timeout_ms, ExceptionSink* xsink);
789
791
800 DLLEXPORT int recvi1(int timeout_ms, char *val);
801
803
811 DLLEXPORT int recvi2(int timeout_ms, short *val);
812
814
822 DLLEXPORT int recvi4(int timeout_ms, int *val);
823
825
833 DLLEXPORT int recvi8(int timeout_ms, int64 *val);
834
836
845 DLLEXPORT int recvi2LSB(int timeout_ms, short *val);
846
848
857 DLLEXPORT int recvi4LSB(int timeout_ms, int *val);
858
860
867 DLLEXPORT int recvi8LSB(int timeout_ms, int64 *val);
868
870
876 DLLEXPORT int recvu1(int timeout_ms, unsigned char *val);
877
879
887 DLLEXPORT int recvu2(int timeout_ms, unsigned short *val);
888
890
898 DLLEXPORT int recvu4(int timeout_ms, unsigned int *val);
899
901
910 DLLEXPORT int recvu2LSB(int timeout_ms, unsigned short *val);
911
913
922 DLLEXPORT int recvu4LSB(int timeout_ms, unsigned int *val);
923
925
935 DLLEXPORT int64 recvi1(int timeout_ms, char *val, ExceptionSink* xsink);
936
938
949 DLLEXPORT int64 recvi2(int timeout_ms, short *val, ExceptionSink* xsink);
950
952
964 DLLEXPORT int64 recvi4(int timeout_ms, int *val, ExceptionSink* xsink);
965
967
978 DLLEXPORT int64 recvi8(int timeout_ms, int64 *val, ExceptionSink* xsink);
979
981
993 DLLEXPORT int64 recvi2LSB(int timeout_ms, short *val, ExceptionSink* xsink);
994
996
1008 DLLEXPORT int64 recvi4LSB(int timeout_ms, int *val, ExceptionSink* xsink);
1009
1011
1022 DLLEXPORT int64 recvi8LSB(int timeout_ms, int64 *val, ExceptionSink* xsink);
1023
1025
1035 DLLEXPORT int64 recvu1(int timeout_ms, unsigned char *val, ExceptionSink* xsink);
1036
1038
1050 DLLEXPORT int64 recvu2(int timeout_ms, unsigned short *val, ExceptionSink* xsink);
1051
1053
1065 DLLEXPORT int64 recvu4(int timeout_ms, unsigned int *val, ExceptionSink* xsink);
1066
1068
1082 DLLEXPORT int64 recvu2LSB(int timeout_ms, unsigned short *val, ExceptionSink* xsink);
1083
1085
1099 DLLEXPORT int64 recvu4LSB(int timeout_ms, unsigned int *val, ExceptionSink* xsink);
1100
1102
1109 DLLEXPORT QoreStringNode *recv(qore_offset_t bufsize, int timeout_ms, int *prc);
1110
1112
1119 DLLEXPORT QoreStringNode* recv(qore_offset_t bufsize, int timeout_ms, ExceptionSink* xsink);
1120
1122
1128 DLLEXPORT BinaryNode *recvBinary(qore_offset_t bufsize, int timeout_ms, int *prc);
1129
1131
1137 DLLEXPORT BinaryNode* recvBinary(qore_offset_t bufsize, int timeout_ms, ExceptionSink* xsink);
1138
1140
1149 DLLEXPORT QoreStringNode *recv(int timeout_ms, int *prc);
1150
1152
1161 DLLEXPORT QoreStringNode* recv(int timeout_ms, ExceptionSink* xsink);
1162
1164
1172 DLLEXPORT BinaryNode *recvBinary(int timeout_ms, int *prc);
1173
1175
1183 DLLEXPORT BinaryNode* recvBinary(int timeout_ms, ExceptionSink* xsink);
1184
1186
1193 DLLEXPORT int recv(int fd, qore_offset_t size, int timeout_ms);
1194
1196
1206 DLLEXPORT int sendHTTPMessage(const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
1207
1209
1220 DLLEXPORT int sendHTTPMessage(QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
1221
1223
1237 DLLEXPORT int sendHTTPMessage(ExceptionSink* xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
1238
1240
1255 DLLEXPORT int sendHTTPMessage(ExceptionSink* xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source, int timeout_ms);
1256
1258
1272 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);
1273
1275
1287 DLLEXPORT int sendHTTPResponse(int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
1288
1290
1303 DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source = QORE_SOURCE_SOCKET);
1304
1306
1320 DLLEXPORT int sendHTTPResponse(ExceptionSink* xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source, int timeout_ms);
1321
1323
1336 DLLEXPORT int sendHTTPResponseWithCallback(ExceptionSink* xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const ResolvedCallReferenceNode& send_callback, int source, int timeout_ms);
1337
1339
1346 DLLEXPORT AbstractQoreNode *readHTTPHeader(int timeout_ms, int *prc, int source = QORE_SOURCE_SOCKET);
1347
1349
1357 DLLEXPORT AbstractQoreNode *readHTTPHeader(QoreHashNode *info, int timeout_ms, int *prc, int source = QORE_SOURCE_SOCKET);
1358
1360
1371 DLLEXPORT QoreHashNode *readHTTPHeader(ExceptionSink* xsink, QoreHashNode *info, int timeout_ms, int source = QORE_SOURCE_SOCKET);
1372
1374
1383 DLLEXPORT QoreStringNode* readHTTPHeaderString(ExceptionSink* xsink, int timeout_ms, int source = QORE_SOURCE_SOCKET);
1384
1386
1395 DLLEXPORT QoreHashNode *readHTTPChunkedBodyBinary(int timeout_ms, ExceptionSink* xsink, int source = QORE_SOURCE_SOCKET);
1396
1398
1409 DLLEXPORT QoreHashNode *readHTTPChunkedBody(int timeout_ms, ExceptionSink* xsink, int source = QORE_SOURCE_SOCKET);
1410
1412 DLLEXPORT int setSendTimeout(int ms);
1413
1415 DLLEXPORT int setRecvTimeout(int ms);
1416
1418 DLLEXPORT int getSendTimeout() const;
1419
1421 DLLEXPORT int getRecvTimeout() const;
1422
1424
1429 DLLEXPORT bool isDataAvailable(int timeout_ms = 0) const;
1430
1432
1441 DLLEXPORT bool isDataAvailable(ExceptionSink* xsink, int timeout_ms = 0) const;
1442
1444
1448 DLLEXPORT int close();
1449
1451
1457 DLLEXPORT int shutdown();
1458
1460
1464 DLLEXPORT int shutdownSSL(ExceptionSink* xsink);
1465
1467
1469 DLLEXPORT int getSocket() const;
1470
1472
1474 DLLEXPORT const QoreEncoding *getEncoding() const;
1475
1477
1479 DLLEXPORT void setEncoding(const QoreEncoding *id);
1480
1482
1484 DLLEXPORT bool isOpen() const;
1485
1487
1489 DLLEXPORT const char *getSSLCipherName() const;
1490
1492
1494 DLLEXPORT const char *getSSLCipherVersion() const;
1495
1497
1499 DLLEXPORT bool isSecure() const;
1500
1502 DLLEXPORT long verifyPeerCertificate() const;
1503
1505
1513 DLLEXPORT int upgradeClientToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
1514
1516
1524 DLLEXPORT int upgradeServerToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink* xsink);
1525
1527
1532 DLLEXPORT bool isWriteFinished(int timeout_ms = 0) const;
1533
1535
1544 DLLEXPORT bool isWriteFinished(ExceptionSink* xsink, int timeout_ms = 0) const;
1545
1547
1558 DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink) const;
1559
1561
1574 DLLEXPORT QoreHashNode* getPeerInfo(ExceptionSink* xsink, bool host_lookup) const;
1575
1577
1590 DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink) const;
1591
1593
1605 DLLEXPORT QoreHashNode* getSocketInfo(ExceptionSink* xsink, bool host_lookup) const;
1606
1607 DLLEXPORT void clearWarningQueue(ExceptionSink* xsink);
1608 DLLEXPORT void setWarningQueue(ExceptionSink* xsink, int64 warning_ms, int64 warning_bs, class Queue* wq, AbstractQoreNode* arg, int64 min_ms = 1000);
1609 DLLEXPORT QoreHashNode* getUsageInfo() const;
1610 DLLEXPORT void clearStats();
1611
1613 DLLEXPORT void cleanup(ExceptionSink* xsink);
1614
1616 DLLEXPORT bool pendingHttpChunkedBody() const;
1617
1618 DLLLOCAL static void doException(int rc, const char *meth, int timeout_ms, ExceptionSink* xsink);
1619
1621 DLLLOCAL void setEventQueue(Queue* cbq, ExceptionSink* xsink);
1622
1624 DLLLOCAL Queue* getQueue();
1625
1627 DLLLOCAL int64 getObjectIDForEvents() const;
1628
1629 DLLLOCAL int setNoDelay(int nodelay);
1630 DLLLOCAL int getNoDelay() const;
1631
1633 DLLLOCAL void setAccept(QoreObject *o);
1634 };
1635
1636 class QoreSocketTimeoutHelper {
1637 protected:
1638 class PrivateQoreSocketTimeoutHelper* priv;
1639 public:
1640 DLLEXPORT QoreSocketTimeoutHelper(QoreSocket& s, const char* op);
1641 DLLEXPORT ~QoreSocketTimeoutHelper();
1642 };
1643
1644 class QoreSocketThroughputHelper {
1645 protected:
1646 class PrivateQoreSocketThroughputHelper* priv;
1647 public:
1648 DLLEXPORT QoreSocketThroughputHelper(QoreSocket& s, bool snd);
1649 DLLEXPORT ~QoreSocketThroughputHelper();
1650 DLLEXPORT void finalize(int64 bytes);
1651 };
1652
1653 #endif // _QORE_QORESOCKET_H
QoreSocket::isOpen
DLLEXPORT bool isOpen() const
returns true if the socket is open
QoreSocket::getSSLCipherVersion
DLLEXPORT const char * getSSLCipherVersion() const
returns the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none
Q_SOCK_STREAM
#define Q_SOCK_STREAM
platform-independent define for SOCK_STREAM
Definition: common.h:56
QoreSocket::readHTTPHeaderString
DLLEXPORT QoreStringNode * readHTTPHeaderString(ExceptionSink *xsink, int timeout_ms, int source=QORE_SOURCE_SOCKET)
read a HTTP header, caller owns QoreStringNode reference count returned
QoreSocket::isSecure
DLLEXPORT bool isSecure() const
returns true if an SSL connection is active
SocketSource::SocketSource
DLLEXPORT SocketSource()
creates an empty object
QoreEncoding
defines string encoding functions in Qore
Definition: QoreEncoding.h:72
SocketSource
a helper class for getting socket origination information
Definition: QoreSocket.h:62
QoreSocket::acceptAndReplace
DLLEXPORT int acceptAndReplace(SocketSource *source)
accepts a new connection on a listening socket and replaces the current socket with the new connectio...
QoreSocket::sendi8LSB
DLLEXPORT int sendi8LSB(int64 i)
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format th...
QoreSocket::sendi1
DLLEXPORT int sendi1(char i)
sends a 1-byte binary integer data to a connected socket
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:41
QoreSocket::bind
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 ...
QoreSocket::getObjectIDForEvents
DLLLOCAL int64 getObjectIDForEvents() const
returns a unique ID for the socket to be used in event messages
QoreSocket::getPeerInfo
DLLEXPORT QoreHashNode * getPeerInfo(ExceptionSink *xsink) const
returns peer information for a connected socket
QoreSocket::getQueue
DLLLOCAL Queue * getQueue()
returns the event queue (not part of the library&#39;s public API)
QoreSocket::verifyPeerCertificate
DLLEXPORT long verifyPeerCertificate() const
returns the peer certificate verification code if an SSL connection is in progress ...
QoreSocket::QoreSocket
DLLEXPORT QoreSocket()
creates an empty, unconnected socket
QoreSocket::readHTTPChunkedBody
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 ...
QoreSocket::recvu1
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...
QoreSocket::readHTTPHeader
DLLEXPORT AbstractQoreNode * readHTTPHeader(int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET)
read and parse HTTP header, caller owns AbstractQoreNode reference count returned ...
QoreSocket::connectUNIX
DLLEXPORT int connectUNIX(const char *p, ExceptionSink *xsink=0)
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in th...
QoreSocket::setAccept
DLLLOCAL void setAccept(QoreObject *o)
sets backwards-compatible members on accept in a new object - will be removed in a future version of ...
QoreSocket::recvi2
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...
SocketSource::getAddress
DLLEXPORT const char * getAddress() const
returns the host address string as a C string
QoreSocket::acceptSSL
DLLEXPORT QoreSocket * acceptSSL(SocketSource *source, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreS...
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
QoreSocket::bindUNIX
DLLEXPORT int bindUNIX(const char *name, ExceptionSink *xsink=0)
binds to a UNIX domain socket and returns a status code
QoreSocket::sendi2LSB
DLLEXPORT int sendi2LSB(short i)
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
QoreSocket::readHTTPChunkedBodyBinary
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 ...
QoreSocket::pendingHttpChunkedBody
DLLEXPORT bool pendingHttpChunkedBody() const
returns true if a HTTP header was read indicating chunked transfer encoding, but no chunked body has ...
QoreSocket::upgradeClientToSSL
DLLEXPORT int upgradeClientToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
negotiates an SSL connection from the client side
QoreSocket::getEncoding
DLLEXPORT const QoreEncoding * getEncoding() const
returns the character encoding associated with this socket
qore_size_t
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:62
QoreSocket::isDataAvailable
DLLEXPORT bool isDataAvailable(int timeout_ms=0) const
returns true if data is available on the socket in the timeout period in milliseconds ...
qore_offset_t
long qore_offset_t
used for offsets that could be negative
Definition: common.h:65
QoreSocket::shutdown
DLLEXPORT int shutdown()
calls shutdown on the socket
QoreSocket::getSocket
DLLEXPORT int getSocket() const
returns the file descriptor associated with this socket
QoreSocket::bindINET
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=0)
binds an INET or INET6 TCP socket to a specific socket address
QoreSocket::recvu2LSB
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...
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
QoreStringNode
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:40
QoreSocket::accept
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...
QoreSocket::recv
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, caller owns the reference count returned
SocketSource::getHostName
DLLEXPORT const char * getHostName() const
returns the hostname string as a C string
QoreSocket::cleanup
DLLEXPORT void cleanup(ExceptionSink *xsink)
posts deleted message and removes any event queue
QoreSocket::~QoreSocket
DLLEXPORT ~QoreSocket()
disconnects if necessary, frees all data, and destroys the socket
QoreSocket::connectINET2SSL
DLLEXPORT int connectINET2SSL(const char *name, const char *service, int family, int sock_type, int protocol, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink=0)
connects to an INET or INET6 socket by hostname and port number or service name and returns a status ...
QoreSocket::setEventQueue
DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink)
sets the event queue (not part of the library&#39;s pubilc API), must be already referenced before call ...
QoreSocket::sendi8
DLLEXPORT int sendi8(int64 i)
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
QoreSocket::recvi4LSB
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...
QoreSocket::recvi2LSB
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...
QoreSocket::recvu4LSB
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...
QoreSocket::connectUNIXSSL
DLLEXPORT int connectUNIXSSL(const char *p, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code...
QoreSocket::sendi4
DLLEXPORT int sendi4(int i)
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
QoreSocket::connectSSL
DLLEXPORT int connectSSL(const char *name, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptio...
QoreSocket::isWriteFinished
DLLEXPORT bool isWriteFinished(int timeout_ms=0) const
returns true if all write data has been written within the timeout period in milliseconds ...
QoreSocket::listen
DLLEXPORT int listen()
sets an open socket to the listening state
QoreSocket::getRecvTimeout
DLLEXPORT int getRecvTimeout() const
get recv timeout in milliseconds
SocketSource::~SocketSource
DLLEXPORT ~SocketSource()
destroys the object and frees all memory
QoreSocket::setEncoding
DLLEXPORT void setEncoding(const QoreEncoding *id)
sets the character encoding for strings sent and received with this socket
SocketSource::takeHostName
DLLEXPORT QoreStringNode * takeHostName()
returns the hostname string field and leaves the object&#39;s hostname field empty; the caller owns the Q...
QoreSocket
provides access to sockets using Qore data structures
Definition: QoreSocket.h:115
QoreObject
the implementation of Qore&#39;s object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:56
QoreSocket::connect
DLLEXPORT int connect(const char *name, ExceptionSink *xsink=0)
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of an...
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
Qore.h
QoreSocket::recvi4
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...
QoreSocket::sendHTTPResponse
DLLEXPORT int sendHTTPResponse(int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP response message on the socket
QoreSocket::recvBinary
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...
QoreSocket::connectINET2
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=0)
connects to an INET or INET6 socket by hostname and port number or service name and returns a status ...
QoreSocket::recvu4
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...
QoreSocket::shutdownSSL
DLLEXPORT int shutdownSSL(ExceptionSink *xsink)
shuts down an active SSL connection
QoreSocket::connectINETSSL
DLLEXPORT int connectINETSSL(const char *host, int prt, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
connects to an INET socket by hostname and port number, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
QoreSocket::sendi2
DLLEXPORT int sendi2(short i)
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
QoreSocket::connectINET
DLLEXPORT int connectINET(const char *host, int prt, ExceptionSink *xsink=0)
connects to an INET socket by hostname and port number and returns a status code, Qore-language excep...
ResolvedCallReferenceNode
base class for resolved call references
Definition: CallReferenceNode.h:120
SocketSource::takeAddress
DLLEXPORT QoreStringNode * takeAddress()
returns the host address string field and leaves the object&#39;s host address field empty; the caller ow...
QoreSocket::recvi8LSB
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...
QoreSocket::getPort
DLLEXPORT int getPort()
returns the TCP port number, also assigns the interal port number if it must be discovered ...
QoreSocket::getSendTimeout
DLLEXPORT int getSendTimeout() const
get send timeout in milliseconds
QoreSocket::setSendTimeout
DLLEXPORT int setSendTimeout(int ms)
set send timeout in milliseconds
QoreSocket::recvi8
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 ...
QoreSocket::sendHTTPResponseWithCallback
DLLEXPORT int sendHTTPResponseWithCallback(ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const ResolvedCallReferenceNode &send_callback, int source, int timeout_ms)
send an HTTP response message on the socket with a chunked message body using a calback ...
QoreSocket::send
DLLEXPORT int send(const char *buf, qore_size_t size)
sends binary data on a connected socket
QoreSocket::setRecvTimeout
DLLEXPORT int setRecvTimeout(int ms)
set recv timeout in milliseconds
QoreSocket::close
DLLEXPORT int close()
closes the socket
QoreSocket::recvi1
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...
QoreSocket::recvu2
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...
Q_AF_UNSPEC
#define Q_AF_UNSPEC
cross-platform define for AF_UNSPEC
Definition: common.h:47
QoreSocket::upgradeServerToSSL
DLLEXPORT int upgradeServerToSSL(X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink)
negotiates an SSL connection from the client side
QoreSocket::getSSLCipherName
DLLEXPORT const char * getSSLCipherName() const
returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none
QoreSocket::sendi4LSB
DLLEXPORT int sendi4LSB(int i)
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format thr...
QoreSocket::sendHTTPMessageWithCallback
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...
QoreSocket::getSocketInfo
DLLEXPORT QoreHashNode * getSocketInfo(ExceptionSink *xsink) const
returns information for the current socket; the socket must be open
QoreSocket::sendHTTPMessage
DLLEXPORT int sendHTTPMessage(const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, qore_size_t size, int source=QORE_SOURCE_SOCKET)
send an HTTP request message on the socket
BinaryNode
holds arbitrary binary data
Definition: BinaryNode.h:33