Qore Programming Language Reference Manual  0.8.13.2
QC_Socket.dox.h
1 namespace Qore {
4 
122 class Socket {
123 
124 public:
126 
140 Socket accept();
141 
142 public:
144 
160 *Socket accept(timeout timeout_ms);
161 
162 public:
164 
180  acceptAllCertificates(bool accept_all = True);
181 
182 public:
184 
198 Socket acceptSSL();
199 
200 public:
202 
218 *Socket acceptSSL(timeout timeout_ms);
219 
220 public:
222 
242 int bind(string str, softbool reuseaddr = False);
243 
244 public:
246 
260 int bind(int port, softbool reuseaddr = False);
261 
262 public:
264 
292 nothing bindINET(*string iface, *softstring service, softbool reuseaddr = False, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
293 
294 public:
296 
312 nothing bindUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
313 
314 public:
316 
325  clearStats();
326 
327 public:
329 
338 nothing clearWarningQueue();
339 
340 public:
342 
355 int close();
356 
357 public:
359 
384 nothing connect(string target, timeout timeout_ms = -1);
385 
386 public:
388 
412 nothing connectINET(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
413 
414 public:
416 
441 nothing connectINETSSL(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
442 
443 public:
445 
473 nothing connectSSL(string target, timeout timeout_ms = -1);
474 
475 public:
477 
496 nothing connectUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
497 
498 public:
500 
520 nothing connectUNIXSSL(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
521 
522 public:
524 
527  constructor();
528 
529 public:
531 
534  copy();
535 
536 public:
538 
556 
557 public:
559 
565 string getCharset();
566 
567 public:
569 
574 string getEncoding();
575 
576 public:
578 
590 bool getNoDelay();
591 
592 public:
594 
610 hash getPeerInfo(bool host_lookup = True);
611 
612 public:
614 
624 int getPort();
625 
626 public:
628 
638 int getRecvTimeout();
639 
640 public:
642 
652 *string getSSLCipherName();
653 
654 public:
656 
666 *string getSSLCipherVersion();
667 
668 public:
670 
680 int getSendTimeout();
681 
682 public:
684 
694 int getSocket();
695 
696 public:
698 
714 hash getSocketInfo(bool host_lookup = True);
715 
716 public:
718 
735 int getSslVerifyMode();
736 
737 public:
739 
761 
762 public:
764 
778 bool isDataAvailable(timeout timeout_ms = 0);
779 
780 public:
782 
792 bool isOpen();
793 
794 public:
796 
806 bool isSecure();
807 
808 public:
810 
824 bool isWriteFinished(timeout timeout_ms = 0);
825 
826 public:
828 
841 int listen(int backlog = 20);
842 
843 public:
845 
853 
854 public:
856 
877 hash readHTTPChunkedBody(timeout timeout_ms = -1);
878 
879 public:
881 
902 hash readHTTPChunkedBodyBinary(timeout timeout_ms = -1);
903 
904 public:
906 
934  readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms = -1);
935 
936 public:
938 
960 hash readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms = -1);
961 
962 public:
964 
992  readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms = -1);
993 
994 public:
996 
1041 hash readHTTPHeader(timeout timeout_ms = -1, *reference<hash> info);
1042 
1043 public:
1045 
1068 string readHTTPHeaderString(timeout timeout_ms = -1);
1069 
1070 public:
1072 
1097 string recv(softint size = 0, timeout timeout_ms = -1);
1098 
1099 public:
1101 
1124 binary recvBinary(softint size = 0, timeout timeout_ms = -1);
1125 
1126 public:
1128 
1151 nothing recvToOutputStream(Qore::OutputStream os, softint size = -1, timeout timeout_ms = -1);
1152 
1153 public:
1155 
1177 int recvi1(timeout timeout_ms = -1);
1178 
1179 public:
1181 
1203 int recvi2(timeout timeout_ms = -1);
1204 
1205 public:
1207 
1229 int recvi2LSB(timeout timeout_ms = -1);
1230 
1231 public:
1233 
1255 int recvi4(timeout timeout_ms = -1);
1256 
1257 public:
1259 
1281 int recvi4LSB(timeout timeout_ms = -1);
1282 
1283 public:
1285 
1307 int recvi8(timeout timeout_ms = -1);
1308 
1309 public:
1311 
1333 int recvi8LSB(timeout timeout_ms = -1);
1334 
1335 public:
1337 
1359 int recvu1(timeout timeout_ms = -1);
1360 
1361 public:
1363 
1385 int recvu2(timeout timeout_ms = -1);
1386 
1387 public:
1389 
1411 int recvu2LSB(timeout timeout_ms = -1);
1412 
1413 public:
1415 
1437 int recvu4(timeout timeout_ms = -1);
1438 
1439 public:
1441 
1463 int recvu4LSB(timeout timeout_ms = -1);
1464 
1465 public:
1467 
1493 int send(binary bin, timeout timeout_ms = -1);
1494 
1495 public:
1497 
1525 int send(string str, timeout timeout_ms = -1);
1526 
1527 public:
1529 
1552 nothing send2(binary bin, timeout timeout_ms = -1);
1553 
1554 public:
1556 
1581 nothing send2(string str, timeout timeout_ms = -1);
1582 
1583 public:
1585 
1610 int sendBinary(string str, timeout timeout_ms = -1);
1611 
1612 public:
1614 
1639 int sendBinary(binary bin, timeout timeout_ms = -1);
1640 
1641 public:
1643 
1665 nothing sendBinary2(string str, timeout timeout_ms = -1);
1666 
1667 public:
1669 
1691 nothing sendBinary2(binary bin, timeout timeout_ms = -1);
1692 
1693 public:
1695 
1716 nothing sendFromInputStream(Qore::InputStream is, softint size = -1, timeout timeout_ms = -1);
1717 
1718 public:
1720 
1743 nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream is, int max_chunk_size = 4096, timeout timeout_ms = -1, *code tcb);
1744 
1745 public:
1747 
1766 nothing sendHTTPChunkedBodyTrailer(*hash trailer, timeout timeout_ms = -1);
1767 
1768 public:
1770 
1798 nothing sendHTTPMessage(string method, string path, string http_version, hash headers, *string body, *reference<hash> info, timeout timeout_ms = -1);
1799 
1800 public:
1802 
1828 nothing sendHTTPMessage(string method, string path, string http_version, hash headers, binary body, *reference<hash> info, timeout timeout_ms = -1);
1829 
1830 public:
1832 
1860 nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash headers, *reference<hash> info, timeout timeout_ms = -1);
1861 
1862 public:
1864 
1888 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash headers, *string body, timeout timeout_ms = -1);
1889 
1890 public:
1892 
1914 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash headers, binary body, timeout timeout_ms = -1);
1915 
1916 public:
1918 
1942 nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash headers, timeout timeout_ms = -1);
1943 
1944 public:
1946 
1969 int sendi1(softint i = 0, timeout timeout_ms = -1);
1970 
1971 public:
1973 
1996 int sendi2(softint i = 0, timeout timeout_ms = -1);
1997 
1998 public:
2000 
2023 int sendi2LSB(softint i = 0, timeout timeout_ms = -1);
2024 
2025 public:
2027 
2050 int sendi4(softint i = 0, timeout timeout_ms = -1);
2051 
2052 public:
2054 
2077 int sendi4LSB(softint i = 0, timeout timeout_ms = -1);
2078 
2079 public:
2081 
2104 int sendi8(softint i = 0, timeout timeout_ms = -1);
2105 
2106 public:
2108 
2131 int sendi8LSB(softint i = 0, timeout timeout_ms = -1);
2132 
2133 public:
2135 
2142 nothing setCertificate(SSLCertificate cert);
2143 
2144 public:
2146 
2153 nothing setCertificate(string cert_pem);
2154 
2155 public:
2157 
2164 nothing setCertificate(binary cert_der);
2165 
2166 public:
2168 
2171 nothing setCharset(string encoding);
2172 
2173 public:
2175 
2177 nothing setEncoding(string encoding);
2178 
2179 public:
2181 
2188 nothing setEventQueue();
2189 
2190 public:
2192 
2203 nothing setEventQueue(Queue queue);
2204 
2205 public:
2207 
2225 int setNoDelay(bool nd = True);
2226 
2227 public:
2229 
2236 nothing setPrivateKey(SSLPrivateKey key);
2237 
2238 public:
2240 
2248 nothing setPrivateKey(string key_pem, *string pass);
2249 
2250 public:
2252 
2259 nothing setPrivateKey(binary key_der);
2260 
2261 public:
2263 
2275 int setRecvTimeout(timeout timeout_ms);
2276 
2277 public:
2279 
2291 int setSendTimeout(timeout timeout_ms);
2292 
2293 public:
2295 
2312  setSslVerifyMode(int mode);
2313 
2314 public:
2316 
2348 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
2349 
2350 public:
2352 
2362 int shutdown();
2363 
2364 public:
2366 
2375 nothing shutdownSSL();
2376 
2377 public:
2379 
2393 nothing upgradeClientToSSL(timeout timeout_ms = -1);
2394 
2395 public:
2397 
2411 nothing upgradeServerToSSL(timeout timeout_ms = -1);
2412 
2413 public:
2415 
2425 *string verifyPeerCertificate();
2426 };
2432 
2434 
2446 
2458 
2467 
2484 
2491 
2493  const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH";
2495  const X509_V_ERR_AKID_SKID_MISMATCH = "X509_V_ERR_AKID_SKID_MISMATCH";
2497  const X509_V_ERR_APPLICATION_VERIFICATION = "X509_V_ERR_APPLICATION_VERIFICATION";
2499  const X509_V_ERR_CERT_CHAIN_TOO_LONG = "X509_V_ERR_CERT_CHAIN_TOO_LONG";
2501  const X509_V_ERR_CERT_HAS_EXPIRED = "X509_V_ERR_CERT_HAS_EXPIRED";
2503  const X509_V_ERR_CERT_NOT_YET_VALID = "X509_V_ERR_CERT_NOT_YET_VALID";
2505  const X509_V_ERR_CERT_REJECTED = "X509_V_ERR_CERT_REJECTED";
2507  const X509_V_ERR_CERT_REVOKED = "X509_V_ERR_CERT_REVOKED";
2509  const X509_V_ERR_CERT_SIGNATURE_FAILURE = "X509_V_ERR_CERT_SIGNATURE_FAILURE";
2511  const X509_V_ERR_CERT_UNTRUSTED = "X509_V_ERR_CERT_UNTRUSTED";
2513  const X509_V_ERR_CRL_HAS_EXPIRED = "X509_V_ERR_CRL_HAS_EXPIRED";
2515  const X509_V_ERR_CRL_NOT_YET_VALID = "X509_V_ERR_CRL_NOT_YET_VALID";
2517  const X509_V_ERR_CRL_SIGNATURE_FAILURE = "X509_V_ERR_CRL_SIGNATURE_FAILURE";
2519  const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT";
2521  const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
2523  const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
2525  const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD";
2527  const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD";
2529  const X509_V_ERR_INVALID_CA = "X509_V_ERR_INVALID_CA";
2531  const X509_V_ERR_INVALID_PURPOSE = "X509_V_ERR_INVALID_PURPOSE";
2533  const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = "X509_V_ERR_KEYUSAGE_NO_CERTSIGN";
2535  const X509_V_ERR_OUT_OF_MEM = "X509_V_ERR_OUT_OF_MEM";
2537  const X509_V_ERR_PATH_LENGTH_EXCEEDED = "X509_V_ERR_PATH_LENGTH_EXCEEDED";
2539  const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN";
2541  const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = "X509_V_ERR_SUBJECT_ISSUER_MISMATCH";
2543  const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY";
2545  const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE";
2547  const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE";
2549  const X509_V_ERR_UNABLE_TO_GET_CRL = "X509_V_ERR_UNABLE_TO_GET_CRL";
2551  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
2553  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY";
2555  const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE";
2557  const X509_V_OK = "X509_V_OK";
2560  "X509_V_OK": "OK",
2561  "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT": "Unable to get issuer certificate",
2562  "X509_V_ERR_UNABLE_TO_GET_CRL": "Unable to get certificate CRL",
2563  "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",
2564  "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE": "Unable to decrypt CRL's signature",
2565  "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY": "Unable to decode issuer public key (SubjectPublicKeyInfo)",
2566  "X509_V_ERR_CERT_SIGNATURE_FAILURE": "Certificate signature failure; the signature of the certificate is invalid",
2567  "X509_V_ERR_CRL_SIGNATURE_FAILURE": "CRL signature failure; the signature of the certificate is invalid",
2568  "X509_V_ERR_CERT_NOT_YET_VALID": "Certificate is not yet valid",
2569  "X509_V_ERR_CERT_HAS_EXPIRED": "Certificate has expired",
2570  "X509_V_ERR_CRL_NOT_YET_VALID": "CRL is not yet valid",
2571  "X509_V_ERR_CRL_HAS_EXPIRED": "CRL has expired",
2572  "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD": "Format error in certificate's notBefore field (invalid time)",
2573  "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD": "Format error in certificate's notAfter field (invalid time)",
2574  "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD": "Format error in CRL's lastUpdate field (invalid time)",
2575  "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD": "Format error in CRL's nextUpdate field (invalid time)",
2576  "X509_V_ERR_OUT_OF_MEM": "Out of memory error",
2577  "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT": "Certificate is self-signed and cannot be found in the trusted list",
2578  "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN": "Self signed certificate in certificate chain",
2579  "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",
2580  "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE": "Unable to verify the first certificate",
2581  "X509_V_ERR_CERT_CHAIN_TOO_LONG": "Certificate chain too long",
2582  "X509_V_ERR_CERT_REVOKED": "Certificate has been revoked",
2583  "X509_V_ERR_INVALID_CA": "Invalid CA certificate",
2584  "X509_V_ERR_PATH_LENGTH_EXCEEDED": "The basicConstraints pathlength parameter has been exceeded",
2585  "X509_V_ERR_INVALID_PURPOSE": "The certificate cannot be used for the specified purpose",
2586  "X509_V_ERR_CERT_UNTRUSTED": "Root CA is not marked as trusted for the specified purpose",
2587  "X509_V_ERR_CERT_REJECTED": "Root CA is marked to reject the specified purpose",
2588  "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",
2589  "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",
2590  "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",
2591  "X509_V_ERR_KEYUSAGE_NO_CERTSIGN": "The keyUsage extension does not permit certificate signing",
2592  "X509_V_ERR_APPLICATION_VERIFICATION": "Verification failure",
2593  );
2595 
2599 
2601  const AFMap = qore(get_network_address_family_map());
2603  const AFStrMap = (
2604  "AF_INET": AF_INET,
2605  "AF_INET6": AF_INET6,
2606  "AF_UNIX": AF_UNIX,
2607  "AF_LOCAL": AF_UNIX,
2608  "AF_UNSPEC": AF_UNSPEC,
2609  );
2611  const AF_INET = AF_INET;
2617  const AF_UNIX = AF_UNIX;
2621 
2626 
2630  const AI_ALL = AI_ALL;
2636 
2641 
2649 
2653 
2657 
2663 
2667 
2675 };
int shutdown()
Ensures that a socket will be closed even if the file descriptor is shared with other processes (for ...
int recvi1(timeout timeout_ms=-1)
Receives a 1-byte signed integer from the socket.
const SSL_VERIFY_NONE
Do not verify the peer&#39;s certificate.
Definition: QC_Socket.dox.h:2465
string recv(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a string tagged with the Socket&#39;s character encoding...
bool isWriteFinished(timeout timeout_ms=0)
Returns True or False depending on whether all the data has been written to the socket.
nothing connectUNIX(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to a UNIX domain socket file.
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:2519
const AF_UNSPEC
unspecified address family
Definition: QC_Socket.dox.h:2619
const SOCK_RAW
raw socket interface, only available to the superuser, untested
Definition: QC_Socket.dox.h:2671
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:2634
const X509_V_ERR_CERT_NOT_YET_VALID
Certificate is not yet valid.
Definition: QC_Socket.dox.h:2503
const X509_V_ERR_OUT_OF_MEM
Out of memory error.
Definition: QC_Socket.dox.h:2535
const X509_V_ERR_PATH_LENGTH_EXCEEDED
The basicConstraints pathlength parameter has been exceeded.
Definition: QC_Socket.dox.h:2537
const AFMap
mapping from Network Address Family Constants to string codes
Definition: QC_Socket.dox.h:2601
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...
const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
Unable to decrypt certificate&#39;s signature. This means that the actual signature value could not be de...
Definition: QC_Socket.dox.h:2545
const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
Format error in CRL&#39;s lastUpdate field (invalid time)
Definition: QC_Socket.dox.h:2525
const X509_V_ERR_APPLICATION_VERIFICATION
Verification failure.
Definition: QC_Socket.dox.h:2497
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...
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:2630
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...
string readHTTPHeaderString(timeout timeout_ms=-1)
Retuns a string representing the data in the HTTP header read (reads until "\r\n\r\n") ...
nothing upgradeServerToSSL(timeout timeout_ms=-1)
Upgrades a server socket connection to a TLS/SSL connection.
The Socket class allows Qore programs safe access to network sockets.
Definition: QC_Socket.dox.h:122
const X509_VerificationReasons
maps from varification strings to verification code descriptions
Definition: QC_Socket.dox.h:2559
int getSendTimeout()
Returns the send timeout socket option value as an integer in milliseconds.
const X509_V_ERR_CERT_UNTRUSTED
Root CA is not marked as trusted for the specified purpose.
Definition: QC_Socket.dox.h:2511
hash getSocketInfo(bool host_lookup=True)
Returns information about the local socket as a hash.
const X509_V_ERR_INVALID_CA
Invalid CA certificate.
Definition: QC_Socket.dox.h:2529
int recvi8LSB(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in little-endian format from the socket.
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 setPrivateKey(SSLPrivateKey key)
Sets the private key to use for negotiating encrypted connections along with the X.509 certificate.
nothing setCertificate(SSLCertificate cert)
Sets the X.509 certificate to use for negotiating encrypted connections.
string getCharset()
Returns the character encoding for the socket.
int recvi2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in little-endian format from the socket.
const True
logical True
Definition: qc_qore.dox.h:94
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 with an...
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:2639
hash getUsageInfo()
Returns performance statistics for the socket.
hash readHTTPChunkedBodyBinary(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
int send(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
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...
int recvi2(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in big-endian format (network byte order) 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.
binary binary()
Always returns an empty binary object (of zero length)
const SSL_VERIFY_PEER
Verify the peer&#39;s certificate.
Definition: QC_Socket.dox.h:2482
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
Unable to get issuer certificate.
Definition: QC_Socket.dox.h:2551
hash readHTTPHeader(timeout timeout_ms=-1, *reference< hash > info)
Retuns a hash representing the data in the HTTP header read, or, if the data cannot be parsed as an H...
*string getSSLCipherVersion()
Returns the version string of the cipher for an encrypted connection or NOTHING if a secure connectio...
hash readHTTPChunkedBody(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
int setSendTimeout(timeout timeout_ms)
sets the send timeout as a socket option
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 recvu2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in little-endian format from the socket.
nothing upgradeClientToSSL(timeout timeout_ms=-1)
Upgrades a client socket connection to a TLS/SSL connection.
const False
logical False
Definition: qc_qore.dox.h:92
string getEncoding()
Returns the character encoding for the socket.
int recvi4LSB(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) signed integer in little-endian format from 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.
int recvi4(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) signed integer in big-endian format (network byte order) from the socket...
nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream is, int max_chunk_size=4096, timeout timeout_ms=-1, *code tcb)
Sends an HTTP message body in chunked transfer encoding.
int listen(int backlog=20)
Listens for connections on a bound socket; sets the socket in a listening state.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash headers, *string body, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and an optional message body...
const AFStrMap
mapping from network address family string codes to Network Address Family Constants ...
Definition: QC_Socket.dox.h:2603
const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
Unable to verify the first certificate.
Definition: QC_Socket.dox.h:2555
const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
Unable to decode issuer public key (SubjectPublicKeyInfo)
Definition: QC_Socket.dox.h:2543
int sendi2LSB(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in little-endian format over the socket.
int getSslVerifyMode()
returns the current SSL verification mode
Socket acceptSSL()
Accepts connections on a listening socket and attempts to negotiate a TLS/SSL connection.
const X509_V_ERR_CRL_NOT_YET_VALID
CRL is not yet valid.
Definition: QC_Socket.dox.h:2515
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:2495
const X509_V_ERR_INVALID_PURPOSE
The certificate cannot be used for the specified purpose.
Definition: QC_Socket.dox.h:2531
int setRecvTimeout(timeout timeout_ms)
sets the receive timeout as a socket option
int getSocket()
Returns the socket file descriptor number.
const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
Format error in CRL&#39;s nextUpdate field (invalid time)
Definition: QC_Socket.dox.h:2527
*string verifyPeerCertificate()
Returns a string code giving the result of verifying the remote certificate or NOTHING if an encrypte...
const SSL_VERIFY_FAIL_IF_NO_PEER_CERT
Require a client certificate in server mode.
Definition: QC_Socket.dox.h:2456
bool getNoDelay()
Returns the TCP_NODELAY setting for 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 connectSSL(string target, timeout timeout_ms=-1)
Connects to a remote socket and attempts to establish a TLS/SSL connection; accepts an optional timeo...
const X509_V_ERR_UNABLE_TO_GET_CRL
Unable to get certificate CRL.
Definition: QC_Socket.dox.h:2549
const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
Format error in certificate&#39;s notAfter field (invalid time)
Definition: QC_Socket.dox.h:2521
const X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The keyUsage extension does not permit certificate signing.
Definition: QC_Socket.dox.h:2533
const X509_V_ERR_CERT_REJECTED
Root CA is marked to reject the specified purpose.
Definition: QC_Socket.dox.h:2505
bool getAcceptAllCertificates()
returns the current value of the "accept all certificates" flag
binary recvBinary(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a binary object.
int sendi1(softint i=0, timeout timeout_ms=-1)
Sends a 1-byte integer over the socket.
This class implements a container for private key data.
Definition: QC_SSLPrivateKey.dox.h:5
hash 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 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...
const AF_INET6
IPv6 address family.
Definition: QC_Socket.dox.h:2613
const AF_INET
IPv4 address family.
Definition: QC_Socket.dox.h:2611
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
This class defines an abstract interface for output streams.
Definition: QC_OutputStream.dox.h:12
const IPPROTO_UDP
for the UDP protocol
Definition: QC_Socket.dox.h:2661
bool pendingHttpChunkedBody()
returns True if the socket is still connected, and a HTTP header was read indicating chunked transfer...
const X509_V_ERR_CERT_SIGNATURE_FAILURE
Certificate signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:2509
constructor()
Creates the socket object.
int sendi4LSB(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in little-endian format over the socket.
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:2553
const X509_V_ERR_CERT_REVOKED
Certificate has been revoked.
Definition: QC_Socket.dox.h:2507
nothing sendHTTPChunkedBodyTrailer(*hash trailer, timeout timeout_ms=-1)
Sends the trialer of an HTTP message body in chunked transfer encoding.
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:2493
const AF_UNIX
UNIX domain address family (UNIX socket files)
Definition: QC_Socket.dox.h:2617
int recvu4LSB(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) unsigned integer in little-endian format from the socket.
const IPPROTO_TCP
for the TCP protocol
Definition: QC_Socket.dox.h:2659
const X509_V_OK
Verification OK.
Definition: QC_Socket.dox.h:2557
int getRecvTimeout()
Returns the receive timeout socket option value as an integer in milliseconds.
const AF_LOCAL
POSIX synonym for AF_UNIX.
Definition: QC_Socket.dox.h:2615
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:2651
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:2541
nothing sendBinary2(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket&#39;s encoding, but instead is sent exactly as-is; 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...
SSLCertificate objects allow Qore code to work with X.509 certificate data.
Definition: QC_SSLCertificate.dox.h:5
hash getPeerInfo(bool host_lookup=True)
Returns a hash of information about the remote end for connected sockets.
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...
acceptAllCertificates(bool accept_all=True)
with peer verification enabled, all certificates are accepted regardless of the validity of the Certi...
const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
Format error in certificate&#39;s notBefore field (invalid time)
Definition: QC_Socket.dox.h:2523
*string getSSLCipherName()
Returns the name of the cipher for an encrypted connection or NOTHING if a secure connection has not ...
copy()
Creates a new Socket object, not based on the source being copied.
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...
const X509_V_ERR_CRL_SIGNATURE_FAILURE
CRL signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:2517
bool isSecure()
Returns True if the connection is a secure TLS/SSL connection.
bool isOpen()
Returns True if the socket is open.
const X509_V_ERR_CERT_HAS_EXPIRED
Certificate has expired.
Definition: QC_Socket.dox.h:2501
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:2632
main Qore-language namespace
Definition: Pseudo_QC_All.dox.h:2
clearStats()
Clears performance statistics.
nothing shutdownSSL()
Shuts down the SSL connection on a secure connection.
This class defines an abstract interface for input streams.
Definition: QC_InputStream.dox.h:12
nothing sendFromInputStream(Qore::InputStream is, softint size=-1, timeout timeout_ms=-1)
Reads data from an InputStream and sends the bytes over the socket.
bool isDataAvailable(timeout timeout_ms=0)
Returns True or False depending on whether there is data to be read on the socket.
hash hash(object obj)
Returns a hash of an object&#39;s members.
const SSL_VERIFY_CLIENT_ONCE
Only request a client certificate once in server mode.
Definition: QC_Socket.dox.h:2444
const SOCK_STREAM
for sequenced, reliable, two-way connection-based byte streams (the default)
Definition: QC_Socket.dox.h:2673
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:2628
nothing setCharset(string encoding)
Sets the character encoding for the socket.
int setNoDelay(bool nd=True)
Sets the boolean TCP_NODELAY setting for the socket.
int sendBinary(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket&#39;s encoding, but instead is sent exactly as-is; if any errors occur, an exception is thrown.
const X509_V_ERR_CERT_CHAIN_TOO_LONG
Certificate chain too long.
Definition: QC_Socket.dox.h:2499
int close()
Closes an open socket.
int recvu2(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in big-endian format (network byte order) from the socket...
nothing setEncoding(string encoding)
Sets the character encoding for the socket.
const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
Self signed certificate in certificate chain.
Definition: QC_Socket.dox.h:2539
const X509_V_ERR_CRL_HAS_EXPIRED
CRL has expired.
Definition: QC_Socket.dox.h:2513
nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash headers, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body as literal binary...
Socket accept()
Accepts connections on a listening socket.
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:2647
int getPort()
Returns the port number of the socket for INET sockets.
nothing setEventQueue()
Removes any Queue object from the Socket object so that socket events are no longer added to the Queu...
nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash headers, *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 recvu1(timeout timeout_ms=-1)
Receives a 1-byte unsigned integer from the socket.
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...
const SOCK_DGRAM
for datagrams (connectionless, unreliable messages of a fixed (typically small) maximum length ...
Definition: QC_Socket.dox.h:2669
const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
Unable to decrypt CRL&#39;s signature.
Definition: QC_Socket.dox.h:2547
nothing sendHTTPMessage(string method, string path, string http_version, hash 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 ...
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 recvToOutputStream(Qore::OutputStream os, softint size=-1, timeout timeout_ms=-1)
Receives data from the socket and writes the bytes to an OutputStream.
setSslVerifyMode(int mode)
sets the SSL verification mode