Qore Programming Language Reference Manual 1.14.0
Loading...
Searching...
No Matches
QC_Socket.dox.h
1
2namespace Qore {
4
6hashdecl SocketPollInfo {
8
10 int events;
13};
14}
15
17namespace Qore {
19
153
154public:
156
172
173public:
175
191*Socket accept(timeout timeout_ms);
192
193public:
195
211 acceptAllCertificates(bool accept_all = True);
212
213public:
215
233
234public:
236
252*Socket acceptSSL(timeout timeout_ms);
253
254public:
256
276int bind(string str, softbool reuseaddr = False);
277
278public:
280
294int bind(int port, softbool reuseaddr = False);
295
296public:
298
326nothing bindINET(*string iface, *softstring service, softbool reuseaddr = False, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
327
328public:
330
346nothing bindUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
347
348public:
350
364
365public:
367
377
378public:
380
390
391public:
393
406int close();
407
408public:
410
448nothing connect(string target, timeout timeout_ms = -1);
449
450public:
452
476nothing connectINET(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
477
478public:
480
505nothing connectINETSSL(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
506
507public:
509
537nothing connectSSL(string target, timeout timeout_ms = -1);
538
539public:
541
560nothing connectUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
561
562public:
564
584nothing connectUNIXSSL(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
585
586public:
588
592
593public:
595
599
600public:
602/***/
604
605public:
607
625
626public:
628
634string getCharset();
635
636public:
638
653
654public:
656
661string getEncoding();
662
663public:
665
678
679public:
681
697hash<auto> getPeerInfo(bool host_lookup = True);
698
699public:
701
712
713public:
715
726
727public:
729
741
742public:
744
756
757public:
759
771
772public:
774
785
786public:
788
799
800public:
802
818hash<auto> getSocketInfo(bool host_lookup = True);
819
820public:
822
840
841public:
843
864hash<auto> getUsageInfo();
865
866public:
868
886bool isDataAvailable(timeout timeout_ms = 0);
887
888public:
890
900bool isOpen();
901
902public:
904
914bool isSecure();
915
916public:
918
935bool isWriteFinished(timeout timeout_ms = 0);
936
937public:
939
952int listen(int backlog = 20);
953
954public:
956
964
965public:
967
988hash<auto> readHTTPChunkedBody(timeout timeout_ms = -1);
989
990public:
992
1013hash<auto> readHTTPChunkedBodyBinary(timeout timeout_ms = -1);
1014
1015public:
1017
1045 readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms = -1);
1046
1047public:
1049
1071hash<auto> readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms = -1);
1072
1073public:
1075
1103 readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms = -1);
1104
1105public:
1107
1154hash<auto> readHTTPHeader(timeout timeout_ms = -1, *reference<hash<auto>> info);
1155
1156public:
1158
1181string readHTTPHeaderString(timeout timeout_ms = -1);
1182
1183public:
1185
1210string recv(softint size = 0, timeout timeout_ms = -1);
1211
1212public:
1214
1237binary recvBinary(softint size = 0, timeout timeout_ms = -1);
1238
1239public:
1241
1264nothing recvToOutputStream(Qore::OutputStream os, softint size = -1, timeout timeout_ms = -1);
1265
1266public:
1268
1290int recvi1(timeout timeout_ms = -1);
1291
1292public:
1294
1316int recvi2(timeout timeout_ms = -1);
1317
1318public:
1320
1342int recvi2LSB(timeout timeout_ms = -1);
1343
1344public:
1346
1373int recvi4(timeout timeout_ms = -1);
1374
1375public:
1377
1399int recvi4LSB(timeout timeout_ms = -1);
1400
1401public:
1403
1425int recvi8(timeout timeout_ms = -1);
1426
1427public:
1429
1451int recvi8LSB(timeout timeout_ms = -1);
1452
1453public:
1455
1477int recvu1(timeout timeout_ms = -1);
1478
1479public:
1481
1503int recvu2(timeout timeout_ms = -1);
1504
1505public:
1507
1529int recvu2LSB(timeout timeout_ms = -1);
1530
1531public:
1533
1555int recvu4(timeout timeout_ms = -1);
1556
1557public:
1559
1581int recvu4LSB(timeout timeout_ms = -1);
1582
1583public:
1585
1611int send(binary bin, timeout timeout_ms = -1);
1612
1613public:
1615
1643int send(string str, timeout timeout_ms = -1);
1644
1645public:
1647
1670nothing send2(binary bin, timeout timeout_ms = -1);
1671
1672public:
1674
1699nothing send2(string str, timeout timeout_ms = -1);
1700
1701public:
1703
1728int sendBinary(string str, timeout timeout_ms = -1);
1729
1730public:
1732
1757int sendBinary(binary bin, timeout timeout_ms = -1);
1758
1759public:
1761
1783nothing sendBinary2(string str, timeout timeout_ms = -1);
1784
1785public:
1787
1809nothing sendBinary2(binary bin, timeout timeout_ms = -1);
1810
1811public:
1813
1834nothing sendFromInputStream(Qore::InputStream input_stream, softint size = -1, timeout timeout_ms = -1);
1835
1836public:
1838
1869nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream input_stream, int max_chunk_size = 4096, timeout timeout_ms = -1, *code tcb);
1870
1871public:
1873
1896nothing sendHTTPChunkedBodyTrailer(*hash<auto> trailer, timeout timeout_ms = -1);
1897
1898public:
1900
1935nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, string body, *reference<hash> info, timeout timeout_ms = -1);
1936
1937public:
1939
1971nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, *binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
1972
1973public:
1975
2003nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
2004
2005public:
2007
2031nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, string body, timeout timeout_ms = -1);
2032
2033public:
2035
2073nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, string body, *reference<hash<auto>> info, timeout timeout_ms = -1);
2074
2075public:
2077
2106nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *binary body, timeout timeout_ms = -1);
2107
2108public:
2110
2144nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
2145
2146public:
2148
2190nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, Qore::InputStream input_stream, int max_chunk_size = 4096, *reference<hash<auto>> info, timeout timeout_ms = -1, *code tcb);
2191
2192public:
2194
2229nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, timeout timeout_ms = -1);
2230
2231public:
2233
2271nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
2272
2273public:
2275
2298int sendi1(softint i = 0, timeout timeout_ms = -1);
2299
2300public:
2302
2325int sendi2(softint i = 0, timeout timeout_ms = -1);
2326
2327public:
2329
2352int sendi2LSB(softint i = 0, timeout timeout_ms = -1);
2353
2354public:
2356
2379int sendi4(softint i = 0, timeout timeout_ms = -1);
2380
2381public:
2383
2406int sendi4LSB(softint i = 0, timeout timeout_ms = -1);
2407
2408public:
2410
2433int sendi8(softint i = 0, timeout timeout_ms = -1);
2434
2435public:
2437
2460int sendi8LSB(softint i = 0, timeout timeout_ms = -1);
2461
2462public:
2464
2472
2473public:
2475
2482nothing setCertificate(string cert_pem);
2483
2484public:
2486
2493nothing setCertificate(binary cert_der);
2494
2495public:
2497
2508
2509public:
2511
2514nothing setCharset(string encoding);
2515
2516public:
2518
2520nothing setEncoding(string encoding);
2521
2522public:
2524
2532
2533public:
2535
2551nothing setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data);
2552
2553public:
2555
2573int setNoDelay(bool nd = True);
2574
2575public:
2577
2585
2586public:
2588
2596nothing setPrivateKey(string key_pem, *string pass);
2597
2598public:
2600
2607nothing setPrivateKey(binary key_der);
2608
2609public:
2611
2625int setRecvTimeout(timeout timeout_ms);
2626
2627public:
2629
2641int setSendTimeout(timeout timeout_ms);
2642
2643public:
2645
2663
2664public:
2666
2698nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
2699
2700public:
2702
2713
2714public:
2716
2725nothing shutdownSSL();
2726
2727public:
2729
2737
2738public:
2740
2750
2751public:
2753
2763
2764public:
2766
2776
2777public:
2779
2789
2790public:
2792
2802
2803public:
2805
2812
2813public:
2815
2822
2823public:
2825
2834
2835public:
2837
2851nothing upgradeClientToSSL(timeout timeout_ms = -1);
2852
2853public:
2855
2869nothing upgradeServerToSSL(timeout timeout_ms = -1);
2870
2871public:
2873
2884
2885public:
2887
2918static list<hash<SocketPollInfo>> poll(list<hash<SocketPollInfo>> items, timeout timeout_ms);
2919};
2923
2931
2936
2938
2950
2962
2971
2988
2995
2997 const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH";
2999 const X509_V_ERR_AKID_SKID_MISMATCH = "X509_V_ERR_AKID_SKID_MISMATCH";
3001 const X509_V_ERR_APPLICATION_VERIFICATION = "X509_V_ERR_APPLICATION_VERIFICATION";
3003 const X509_V_ERR_CERT_CHAIN_TOO_LONG = "X509_V_ERR_CERT_CHAIN_TOO_LONG";
3005 const X509_V_ERR_CERT_HAS_EXPIRED = "X509_V_ERR_CERT_HAS_EXPIRED";
3007 const X509_V_ERR_CERT_NOT_YET_VALID = "X509_V_ERR_CERT_NOT_YET_VALID";
3009 const X509_V_ERR_CERT_REJECTED = "X509_V_ERR_CERT_REJECTED";
3011 const X509_V_ERR_CERT_REVOKED = "X509_V_ERR_CERT_REVOKED";
3013 const X509_V_ERR_CERT_SIGNATURE_FAILURE = "X509_V_ERR_CERT_SIGNATURE_FAILURE";
3015 const X509_V_ERR_CERT_UNTRUSTED = "X509_V_ERR_CERT_UNTRUSTED";
3017 const X509_V_ERR_CRL_HAS_EXPIRED = "X509_V_ERR_CRL_HAS_EXPIRED";
3019 const X509_V_ERR_CRL_NOT_YET_VALID = "X509_V_ERR_CRL_NOT_YET_VALID";
3021 const X509_V_ERR_CRL_SIGNATURE_FAILURE = "X509_V_ERR_CRL_SIGNATURE_FAILURE";
3023 const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT";
3025 const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
3027 const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
3029 const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD";
3031 const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD";
3033 const X509_V_ERR_INVALID_CA = "X509_V_ERR_INVALID_CA";
3035 const X509_V_ERR_INVALID_PURPOSE = "X509_V_ERR_INVALID_PURPOSE";
3037 const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = "X509_V_ERR_KEYUSAGE_NO_CERTSIGN";
3039 const X509_V_ERR_OUT_OF_MEM = "X509_V_ERR_OUT_OF_MEM";
3041 const X509_V_ERR_PATH_LENGTH_EXCEEDED = "X509_V_ERR_PATH_LENGTH_EXCEEDED";
3043 const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN";
3045 const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = "X509_V_ERR_SUBJECT_ISSUER_MISMATCH";
3047 const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY";
3049 const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE";
3051 const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE";
3053 const X509_V_ERR_UNABLE_TO_GET_CRL = "X509_V_ERR_UNABLE_TO_GET_CRL";
3055 const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
3057 const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY";
3059 const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE";
3061 const X509_V_OK = "X509_V_OK";
3064 "X509_V_OK": "OK",
3065 "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT": "Unable to get issuer certificate",
3066 "X509_V_ERR_UNABLE_TO_GET_CRL": "Unable to get certificate CRL",
3067 "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE": "Unable to decrypt certificate's signature. This means that the actual signature value could not be determined rather than it not matching the expected value; this is only meaningful for RSA",
3068 "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE": "Unable to decrypt CRL's signature",
3069 "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY": "Unable to decode issuer public key (SubjectPublicKeyInfo)",
3070 "X509_V_ERR_CERT_SIGNATURE_FAILURE": "Certificate signature failure; the signature of the certificate is invalid",
3071 "X509_V_ERR_CRL_SIGNATURE_FAILURE": "CRL signature failure; the signature of the certificate is invalid",
3072 "X509_V_ERR_CERT_NOT_YET_VALID": "Certificate is not yet valid",
3073 "X509_V_ERR_CERT_HAS_EXPIRED": "Certificate has expired",
3074 "X509_V_ERR_CRL_NOT_YET_VALID": "CRL is not yet valid",
3075 "X509_V_ERR_CRL_HAS_EXPIRED": "CRL has expired",
3076 "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD": "Format error in certificate's notBefore field (invalid time)",
3077 "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD": "Format error in certificate's notAfter field (invalid time)",
3078 "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD": "Format error in CRL's lastUpdate field (invalid time)",
3079 "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD": "Format error in CRL's nextUpdate field (invalid time)",
3080 "X509_V_ERR_OUT_OF_MEM": "Out of memory error",
3081 "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT": "Certificate is self-signed and cannot be found in the trusted list",
3082 "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN": "Self signed certificate in certificate chain",
3083 "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY": "Unable to get local issuer certificate. This normally means the list of trusted certificates is not complete",
3084 "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE": "Unable to verify the first certificate",
3085 "X509_V_ERR_CERT_CHAIN_TOO_LONG": "Certificate chain too long",
3086 "X509_V_ERR_CERT_REVOKED": "Certificate has been revoked",
3087 "X509_V_ERR_INVALID_CA": "Invalid CA certificate",
3088 "X509_V_ERR_PATH_LENGTH_EXCEEDED": "The basicConstraints pathlength parameter has been exceeded",
3089 "X509_V_ERR_INVALID_PURPOSE": "The certificate cannot be used for the specified purpose",
3090 "X509_V_ERR_CERT_UNTRUSTED": "Root CA is not marked as trusted for the specified purpose",
3091 "X509_V_ERR_CERT_REJECTED": "Root CA is marked to reject the specified purpose",
3092 "X509_V_ERR_SUBJECT_ISSUER_MISMATCH": "The current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate",
3093 "X509_V_ERR_AKID_SKID_MISMATCH": "The current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier of the current certificate",
3094 "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH": "Issuer name and serial number of candidate certificate do not match the authority key identifier of the current certificate",
3095 "X509_V_ERR_KEYUSAGE_NO_CERTSIGN": "The keyUsage extension does not permit certificate signing",
3096 "X509_V_ERR_APPLICATION_VERIFICATION": "Verification failure",
3097);
3099
3103
3105 const AFMap = qore(get_network_address_family_map());
3107 const AFStrMap = (
3108 "AF_INET": AF_INET,
3109 "AF_INET6": AF_INET6,
3110 "AF_UNIX": AF_UNIX,
3111 "AF_LOCAL": AF_UNIX,
3112 "AF_UNSPEC": AF_UNSPEC,
3113);
3125
3130
3140
3147
3158
3162
3166
3172
3176
3184}
Abstract poll operation objects provide the polling interface for pollable objects.
Definition: QC_AbstractPollOperation.dox.h:6
Interface for builtin classes that support I/O polling.
Definition: QC_AbstractPollableIoObjectBase.dox.h:8
This interfaces declares that the inheriting class supports a pollable file descriptor.
Definition: QC_AbstractPollableIoObject.dox.h:6
This class defines an abstract interface for input streams.
Definition: QC_InputStream.dox.h:19
This class defines an abstract interface for output streams.
Definition: QC_OutputStream.dox.h:18
SSLCertificate objects allow Qore code to work with X.509 certificate data.
Definition: QC_SSLCertificate.dox.h:10
This class implements a container for private key data.
Definition: QC_SSLPrivateKey.dox.h:10
The Socket class allows Qore programs safe access to network sockets.
Definition: QC_Socket.dox.h:152
int sendi2LSB(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in little-endian format over the socket.
nothing send2(string str, timeout timeout_ms=-1)
Sends string data over the socket; string data is converted to the socket's encoding if necessary; if...
int getSendTimeout()
Returns the send timeout socket option value as an integer in milliseconds.
hash< auto > readHTTPChunkedBodyBinary(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
int sendBinary(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
nothing sendHTTPMessage(string method, string path, string http_version, hash< auto > headers, *binary body, *reference< hash< auto > > info, timeout timeout_ms=-1)
Sends an HTTP message with a method and user-defined headers given as a hash and an optional message ...
bool getAcceptAllCertificates()
returns the current value of the "accept all certificates" flag
int sendi1(softint i=0, timeout timeout_ms=-1)
Sends a 1-byte integer over the socket.
int sendi8LSB(softint i=0, timeout timeout_ms=-1)
Sends an 8-byte (64-bit) integer in little-endian format over the socket.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, *binary body, *reference< hash< auto > > info, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body as literal binary...
bool pendingHttpChunkedBody()
returns True if the socket is still connected, and a HTTP header was read indicating chunked transfer...
bool captureRemoteCertificates(bool set=True)
Sets the flag for capturing remote X.509 certificates; by default no capture of remote certificates i...
bool isOpen()
Returns True if the socket is open.
int recvu2(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in big-endian format (network byte order) from the socket...
int getSocket()
Returns the socket file descriptor number.
hash< auto > getSocketInfo(bool host_lookup=True)
Returns information about the local socket as a hash.
AbstractPollOperation startPollConnectSsl(string target)
Returns an AbstractPollOperation object to poll the socket for an SSL connection.
int setRecvTimeout(timeout timeout_ms)
sets the receive timeout as a socket option
Socket accept()
Accepts connections on a listening socket.
bool getNoDelay()
Returns the TCP_NODELAY setting for the socket.
nothing connectSSL(string target, timeout timeout_ms=-1)
Connects to a remote socket and attempts to establish a TLS/SSL connection; accepts an optional timeo...
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, string body, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and an optional message body.
nothing setCertificate(binary cert_der)
Sets the X.509 certificate to use for negotiating encrypted connections from the DER-encoded binary o...
nothing sendFromInputStream(Qore::InputStream input_stream, softint size=-1, timeout timeout_ms=-1)
Reads data from an InputStream and sends the bytes over the socket.
int close()
Closes an open socket.
AbstractPollOperation startPollRecvBinary(int size)
Returns an AbstractPollOperation object to read data in non-blocking mode.
*string getSSLCipherName()
Returns the name of the cipher for an encrypted connection or NOTHING if a secure connection has not ...
int listen(int backlog=20)
Listens for connections on a bound socket; sets the socket in a listening state.
nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash< auto > headers, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body to send with chun...
static list< hash< SocketPollInfo > > poll(list< hash< SocketPollInfo > > items, timeout timeout_ms)
polls multiple sockets and returns all sockets with events
*Socket accept(timeout timeout_ms)
Accepts connections on a listening socket (see Socket::listen()) accepting a timeout value with a mil...
*string getSSLCipherVersion()
Returns the version string of the cipher for an encrypted connection or NOTHING if a secure connectio...
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
int recvu4LSB(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) unsigned integer in little-endian format from the socket.
int recvi2(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in big-endian format (network byte order) from the socket.
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
bool isWriteFinished(timeout timeout_ms=0)
Returns True or False depending on whether all the data has been written to the socket.
nothing connectUNIXSSL(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given UNIX domain socket file and attempts to establish a TLS/SSL connection.
nothing setCertificateAndPrivateKey(SSLCertificate cert, SSLPrivateKey key)
Sets the X.509 certificate and private key in one atomic operation to use for negotiating encrypted c...
nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash< auto > headers, *reference< hash< auto > > info, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body to send with chun...
*string verifyPeerCertificate()
Returns a string code giving the result of verifying the remote certificate or NOTHING if an encrypte...
hash< auto > readHTTPChunkedBody(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
int recvi4LSB(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) signed integer in little-endian format from the socket.
bool isSecure()
Returns True if the connection is a secure TLS/SSL connection.
AbstractPollOperation startPollUpgradeClientToSSL()
Returns an AbstractPollOperation object to upgrade a connected client socket to SSL.
hash< auto > readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding, writes it in an OutputStream and ret...
nothing sendBinary2(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket's encoding,...
*Socket acceptSSL(timeout timeout_ms)
Accepts connections on a listening socket and attempts to negotiate a TLS/SSL connection accepting a ...
int sendi4LSB(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in little-endian format over the socket.
int getConnectionId()
Returns an integer connection ID that is incremented every time the socket is disconnected.
nothing connectINETSSL(string host, softstring service, timeout timeout_ms=-1, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given host and port and attempts to establish a TLS/SSL connection; accepts an option...
*SSLCertificate getRemoteCertificate()
Returns any remote certificate captured or NOTHING if there is none.
hash< auto > getPeerInfo(bool host_lookup=True)
Returns a hash of information about the remote end for connected sockets.
int getSslVerifyMode()
returns the current SSL verification mode
AbstractPollOperation startPollConnect(string target)
Returns an AbstractPollOperation object to poll the socket for a standard connection.
nothing connectINET(string host, softstring service, timeout timeout_ms=-1, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given host and port with an optional timeout value with a millisecond resolution.
int recvi8LSB(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in little-endian format from the socket.
nothing connect(string target, timeout timeout_ms=-1)
Connects to a remote port (if the string has a format "host:port") or UNIX domain socket file.
int bind(int port, softbool reuseaddr=False)
Opens and binds the socket to an INET port on all interfaces.
nothing setPrivateKey(string key_pem, *string pass)
Sets the private key to use for negotiating encrypted connections along with the X....
nothing upgradeServerToSSL(timeout timeout_ms=-1)
Upgrades a server socket connection to a TLS/SSL connection.
int bind(string str, softbool reuseaddr=False)
Opens and binds the socket to a port, interface and port (if the bind_to string has a format "host:po...
AbstractPollOperation startPollRecvUntilBytesString(string pattern)
Returns an AbstractPollOperation object to read data in non-blocking mode.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, Qore::InputStream input_stream, int max_chunk_size=4096, *reference< hash< auto > > info, timeout timeout_ms=-1, *code tcb)
Sends an HTTP response with user-defined headers and a message body from an input stream in chunked t...
nothing sendBinary2(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
int sendi8(softint i=0, timeout timeout_ms=-1)
Sends an 8-byte (64-bit) integer in big-endian format (network byte order) over the socket.
nothing bindINET(*string iface, *softstring service, softbool reuseaddr=False, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Opens and binds the socket to the given IPv4 or IPv6 interface (or if no interface is given,...
int sendi4(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in big-endian format (network byte order) over the socket.
AbstractPollOperation startPollSend(binary data)
Returns an AbstractPollOperation object to send data in non-blocking mode.
nothing recvToOutputStream(Qore::OutputStream os, softint size=-1, timeout timeout_ms=-1)
Receives data from the socket and writes the bytes to an OutputStream.
nothing setCertificate(SSLCertificate cert)
Sets the X.509 certificate to use for negotiating encrypted connections.
readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
int recvi1(timeout timeout_ms=-1)
Receives a 1-byte signed integer from the socket.
int getRecvTimeout()
Returns the receive timeout socket option value as an integer in milliseconds.
nothing setCertificate(string cert_pem)
Sets the X.509 certificate to use for negotiating encrypted connections from the PEM-encoded string r...
clearStats()
Clears performance statistics.
int recvu2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in little-endian format from the socket.
binary recvBinary(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a binary object.
int send(string str, timeout timeout_ms=-1)
Sends string data over the socket; string data is converted to the socket's encoding if necessary; if...
readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
acceptAllCertificates(bool accept_all=True)
with peer verification enabled, all certificates are accepted regardless of the validity of the Certi...
int send(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
AbstractPollOperation startPollRecvString(int size)
Returns an AbstractPollOperation object to read data in non-blocking mode.
nothing setPrivateKey(binary key_der)
Sets the private key to use for negotiating encrypted connections along with the X....
int setSendTimeout(timeout timeout_ms)
sets the send timeout as a socket option
copy()
Creates a new Socket object, not based on the source being copied.
int sendi2(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in big-endian format (network byte order) over the socket.
setSslVerifyMode(int mode)
sets the SSL verification mode
int shutdown()
Ensures that a socket will be closed even if the file descriptor is shared with other processes (for ...
nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash< auto > headers, *reference< hash< auto > > info, timeout timeout_ms=-1)
Sends an HTTP message with a method and user-defined headers given as a hash and an optional message ...
constructor()
Creates the socket object.
nothing shutdownSSL()
Shuts down the SSL connection on a secure connection.
AbstractPollOperation startPollRecvUntilBytesBinary(string pattern)
Returns an AbstractPollOperation object to read data in non-blocking mode.
nothing setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
int recvu1(timeout timeout_ms=-1)
Receives a 1-byte unsigned integer from the socket.
nothing send2(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
AbstractPollOperation startPollSend(string data)
Returns an AbstractPollOperation object to send data in non-blocking mode.
string readHTTPHeaderString(timeout timeout_ms=-1)
Retuns a string representing the data in the HTTP header read (reads until "\r\n\r\n")
int recvi4(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) signed integer in big-endian format (network byte order) from the socket.
string getEncoding()
Returns the character encoding for the socket.
hash< auto > readHTTPHeader(timeout timeout_ms=-1, *reference< hash< auto > > info)
Retuns a hash representing the data in the HTTP header read, or, if the data cannot be parsed as an H...
nothing setEventQueue()
Removes any Queue object from the Socket object so that socket events are no longer added to the Queu...
nothing sendHTTPChunkedBodyTrailer(*hash< auto > trailer, timeout timeout_ms=-1)
Sends the trialer of an HTTP message body in chunked transfer encoding.
nothing upgradeClientToSSL(timeout timeout_ms=-1)
Upgrades a client socket connection to a TLS/SSL connection.
nothing setCharset(string encoding)
Sets the character encoding for the socket.
nothing connectUNIX(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to a UNIX domain socket file.
int sendBinary(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket's encoding,...
bool isDataAvailable(timeout timeout_ms=0)
Returns True or False depending on whether there is data to be read on the socket.
int setNoDelay(bool nd=True)
Sets the boolean TCP_NODELAY setting for the socket.
Socket acceptSSL()
Accepts connections on a listening socket and attempts to negotiate a TLS/SSL connection.
string recv(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a string tagged with the Socket's character encoding.
int recvu4(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) unsigned integer in big-endian format (network byte order) from the socket...
int recvi8(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in big-endian format (network byte order) from the socket.
nothing sendHTTPMessage(string method, string path, string http_version, hash< auto > headers, string body, *reference< hash > info, timeout timeout_ms=-1)
Sends an HTTP message with a method and user-defined headers given as a hash and an optional message ...
int recvi2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in little-endian format from the socket.
int getPort()
Returns the port number of the socket for INET sockets.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, *binary body, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body as literal binary...
nothing bindUNIX(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Opens and binds the socket to the given UNIX domain socket file as given by the filename argument....
nothing setEncoding(string encoding)
Sets the character encoding for the socket.
destructor()
Deletes the object.
nothing setPrivateKey(SSLPrivateKey key)
Sets the private key to use for negotiating encrypted connections along with the X....
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, string body, *reference< hash< auto > > info, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and an optional message body.
nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream input_stream, int max_chunk_size=4096, timeout timeout_ms=-1, *code tcb)
Sends an HTTP message body in chunked transfer encoding.
string getCharset()
Returns the character encoding for the socket.
Queue objects provide a blocking, thread-safe message-passing object to Qore programs
Definition: QC_Queue.dox.h:22
const True
logical True
Definition: qc_qore.dox.h:98
const False
logical False
Definition: qc_qore.dox.h:96
const AF_LOCAL
POSIX synonym for AF_UNIX.
Definition: QC_Socket.dox.h:3119
const AF_INET6
IPv6 address family.
Definition: QC_Socket.dox.h:3117
const AF_UNIX
UNIX domain address family (UNIX socket files)
Definition: QC_Socket.dox.h:3121
const AFMap
mapping from Network Address Family Constants to string codes
Definition: QC_Socket.dox.h:3105
const AF_UNSPEC
unspecified address family
Definition: QC_Socket.dox.h:3123
const AF_INET
IPv4 address family.
Definition: QC_Socket.dox.h:3115
const AFStrMap
mapping from network address family string codes to Network Address Family Constants
Definition: QC_Socket.dox.h:3107
const AI_NUMERICHOST
If this bit is set, then the host is assumed to be an address and no hostname lookup will be preforme...
Definition: QC_Socket.dox.h:3138
const AI_ADDRCONFIG
if this bit is set, addresses of each family are returned only if they are configured on the system
Definition: QC_Socket.dox.h:3132
const AI_CANONNAME
If this bit is set, then getaddrinfo() will return the canonical name of the hostname in the "canonna...
Definition: QC_Socket.dox.h:3136
const AI_ALL
If this bit is set along with AI_V4MAPPED then all matching IPv6 and IPv4 addresses are returned.
Definition: QC_Socket.dox.h:3134
const AI_NUMERICSERV
If this bit is set, then the service is assumed to be a numeric port string, and no service lookup wi...
Definition: QC_Socket.dox.h:3145
const AI_V4MAPPED
If this bit is set, getaddrinfo() will return IPv4-mapped IPv6 addresses on finding no matching IPv6 ...
Definition: QC_Socket.dox.h:3160
const AI_PASSIVE
If this bit is set, then the returned information should be usable for a call to Socket::bind()
Definition: QC_Socket.dox.h:3156
const IPPROTO_TCP
for the TCP protocol
Definition: QC_Socket.dox.h:3168
const IPPROTO_UDP
for the UDP protocol
Definition: QC_Socket.dox.h:3170
const SOCK_POLLIN
(input and output) for polling for read events
Definition: QC_Socket.dox.h:2927
const SOCK_POLLERR
(output only) indicates that the socket or connection is closed
Definition: QC_Socket.dox.h:2925
const SOCK_POLLOUT
(input and output) for polling for write events
Definition: QC_Socket.dox.h:2929
const SOCK_STREAM
for sequenced, reliable, two-way connection-based byte streams (the default)
Definition: QC_Socket.dox.h:3182
const SOCK_RAW
raw socket interface, only available to the superuser, untested
Definition: QC_Socket.dox.h:3180
const SOCK_DGRAM
for datagrams (connectionless, unreliable messages of a fixed (typically small) maximum length
Definition: QC_Socket.dox.h:3178
const SSL_VERIFY_NONE
Do not verify the peer's certificate.
Definition: QC_Socket.dox.h:2969
const SSL_VERIFY_FAIL_IF_NO_PEER_CERT
Require a client certificate in server mode.
Definition: QC_Socket.dox.h:2960
const SSL_VERIFY_CLIENT_ONCE
Only request a client certificate once in server mode.
Definition: QC_Socket.dox.h:2948
const SSL_VERIFY_PEER
Verify the peer's certificate.
Definition: QC_Socket.dox.h:2986
list< auto > list(...)
Returns a list of the arguments passed at the top level.
binary binary()
Always returns an empty binary object (of zero length)
const X509_V_ERR_CERT_SIGNATURE_FAILURE
Certificate signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:3013
const X509_V_ERR_CERT_REJECTED
Root CA is marked to reject the specified purpose.
Definition: QC_Socket.dox.h:3009
const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
Issuer name and serial number of candidate certificate do not match the authority key identifier of t...
Definition: QC_Socket.dox.h:2997
const X509_VerificationReasons
maps from varification strings to verification code descriptions
Definition: QC_Socket.dox.h:3063
const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
Format error in certificate's notBefore field (invalid time)
Definition: QC_Socket.dox.h:3027
const X509_V_ERR_PATH_LENGTH_EXCEEDED
The basicConstraints pathlength parameter has been exceeded.
Definition: QC_Socket.dox.h:3041
const X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The keyUsage extension does not permit certificate signing.
Definition: QC_Socket.dox.h:3037
const X509_V_ERR_INVALID_PURPOSE
The certificate cannot be used for the specified purpose.
Definition: QC_Socket.dox.h:3035
const X509_V_ERR_APPLICATION_VERIFICATION
Verification failure.
Definition: QC_Socket.dox.h:3001
const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
Certificate is self-signed and cannot be found in the trusted list.
Definition: QC_Socket.dox.h:3023
const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
Unable to decrypt certificate's signature. This means that the actual signature value could not be de...
Definition: QC_Socket.dox.h:3049
const X509_V_ERR_UNABLE_TO_GET_CRL
Unable to get certificate CRL.
Definition: QC_Socket.dox.h:3053
const X509_V_OK
Verification OK.
Definition: QC_Socket.dox.h:3061
const X509_V_ERR_CRL_NOT_YET_VALID
CRL is not yet valid.
Definition: QC_Socket.dox.h:3019
const X509_V_ERR_CERT_CHAIN_TOO_LONG
Certificate chain too long.
Definition: QC_Socket.dox.h:3003
const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
Unable to get local issuer certificate. This normally means the list of trusted certificates is not c...
Definition: QC_Socket.dox.h:3057
const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
Unable to verify the first certificate.
Definition: QC_Socket.dox.h:3059
const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
Unable to decode issuer public key (SubjectPublicKeyInfo)
Definition: QC_Socket.dox.h:3047
const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
Format error in CRL's nextUpdate field (invalid time)
Definition: QC_Socket.dox.h:3031
const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
Format error in CRL's lastUpdate field (invalid time)
Definition: QC_Socket.dox.h:3029
const X509_V_ERR_CERT_REVOKED
Certificate has been revoked.
Definition: QC_Socket.dox.h:3011
const X509_V_ERR_SUBJECT_ISSUER_MISMATCH
The current candidate issuer certificate was rejected because its subject name did not match the issu...
Definition: QC_Socket.dox.h:3045
const X509_V_ERR_INVALID_CA
Invalid CA certificate.
Definition: QC_Socket.dox.h:3033
const X509_V_ERR_OUT_OF_MEM
Out of memory error.
Definition: QC_Socket.dox.h:3039
const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
Unable to get issuer certificate.
Definition: QC_Socket.dox.h:3055
const X509_V_ERR_CRL_HAS_EXPIRED
CRL has expired.
Definition: QC_Socket.dox.h:3017
const X509_V_ERR_CERT_UNTRUSTED
Root CA is not marked as trusted for the specified purpose.
Definition: QC_Socket.dox.h:3015
const X509_V_ERR_CERT_NOT_YET_VALID
Certificate is not yet valid.
Definition: QC_Socket.dox.h:3007
const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
Format error in certificate's notAfter field (invalid time)
Definition: QC_Socket.dox.h:3025
const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
Unable to decrypt CRL's signature.
Definition: QC_Socket.dox.h:3051
const X509_V_ERR_CERT_HAS_EXPIRED
Certificate has expired.
Definition: QC_Socket.dox.h:3005
const X509_V_ERR_AKID_SKID_MISMATCH
The current candidate issuer certificate was rejected because its subject key identifier was present ...
Definition: QC_Socket.dox.h:2999
const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
Self signed certificate in certificate chain.
Definition: QC_Socket.dox.h:3043
const X509_V_ERR_CRL_SIGNATURE_FAILURE
CRL signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:3021
Qore namespace.
Definition: QC_AbstractSmartLock.dox.h:2
Socket or other pollable object poll info hash.
Definition: QC_Socket.dox.h:6
int events
The poll type; see Socket Poll Constants for possible values to be combined with binary or.
Definition: QC_Socket.dox.h:10
Qore::AbstractPollableIoObject socket
the pollable object to monitor
Definition: QC_Socket.dox.h:12