Qore Programming Language Reference Manual  0.9.3
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 
329 bool captureRemoteCertificates(bool set = True);
330 
331 public:
333 
342  clearStats();
343 
344 public:
346 
355 nothing clearWarningQueue();
356 
357 public:
359 
372 int close();
373 
374 public:
376 
401 nothing connect(string target, timeout timeout_ms = -1);
402 
403 public:
405 
429 nothing connectINET(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
430 
431 public:
433 
458 nothing connectINETSSL(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
459 
460 public:
462 
490 nothing connectSSL(string target, timeout timeout_ms = -1);
491 
492 public:
494 
513 nothing connectUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
514 
515 public:
517 
537 nothing connectUNIXSSL(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
538 
539 public:
541 
544  constructor();
545 
546 public:
548 
551  copy();
552 
553 public:
555 
573 
574 public:
576 
582 string getCharset();
583 
584 public:
586 
591 string getEncoding();
592 
593 public:
595 
607 bool getNoDelay();
608 
609 public:
611 
627 hash<auto> getPeerInfo(bool host_lookup = True);
628 
629 public:
631 
641 int getPort();
642 
643 public:
645 
655 int getRecvTimeout();
656 
657 public:
659 
671 
672 public:
674 
684 *string getSSLCipherName();
685 
686 public:
688 
698 *string getSSLCipherVersion();
699 
700 public:
702 
712 int getSendTimeout();
713 
714 public:
716 
726 int getSocket();
727 
728 public:
730 
746 hash<auto> getSocketInfo(bool host_lookup = True);
747 
748 public:
750 
767 int getSslVerifyMode();
768 
769 public:
771 
792 hash<auto> getUsageInfo();
793 
794 public:
796 
810 bool isDataAvailable(timeout timeout_ms = 0);
811 
812 public:
814 
824 bool isOpen();
825 
826 public:
828 
838 bool isSecure();
839 
840 public:
842 
856 bool isWriteFinished(timeout timeout_ms = 0);
857 
858 public:
860 
873 int listen(int backlog = 20);
874 
875 public:
877 
885 
886 public:
888 
909 hash<auto> readHTTPChunkedBody(timeout timeout_ms = -1);
910 
911 public:
913 
934 hash<auto> readHTTPChunkedBodyBinary(timeout timeout_ms = -1);
935 
936 public:
938 
966  readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms = -1);
967 
968 public:
970 
992 hash<auto> readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms = -1);
993 
994 public:
996 
1024  readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms = -1);
1025 
1026 public:
1028 
1075 hash<auto> readHTTPHeader(timeout timeout_ms = -1, *reference<hash<auto>> info);
1076 
1077 public:
1079 
1102 string readHTTPHeaderString(timeout timeout_ms = -1);
1103 
1104 public:
1106 
1131 string recv(softint size = 0, timeout timeout_ms = -1);
1132 
1133 public:
1135 
1158 binary recvBinary(softint size = 0, timeout timeout_ms = -1);
1159 
1160 public:
1162 
1185 nothing recvToOutputStream(Qore::OutputStream os, softint size = -1, timeout timeout_ms = -1);
1186 
1187 public:
1189 
1211 int recvi1(timeout timeout_ms = -1);
1212 
1213 public:
1215 
1237 int recvi2(timeout timeout_ms = -1);
1238 
1239 public:
1241 
1263 int recvi2LSB(timeout timeout_ms = -1);
1264 
1265 public:
1267 
1289 int recvi4(timeout timeout_ms = -1);
1290 
1291 public:
1293 
1315 int recvi4LSB(timeout timeout_ms = -1);
1316 
1317 public:
1319 
1341 int recvi8(timeout timeout_ms = -1);
1342 
1343 public:
1345 
1367 int recvi8LSB(timeout timeout_ms = -1);
1368 
1369 public:
1371 
1393 int recvu1(timeout timeout_ms = -1);
1394 
1395 public:
1397 
1419 int recvu2(timeout timeout_ms = -1);
1420 
1421 public:
1423 
1445 int recvu2LSB(timeout timeout_ms = -1);
1446 
1447 public:
1449 
1471 int recvu4(timeout timeout_ms = -1);
1472 
1473 public:
1475 
1497 int recvu4LSB(timeout timeout_ms = -1);
1498 
1499 public:
1501 
1527 int send(binary bin, timeout timeout_ms = -1);
1528 
1529 public:
1531 
1559 int send(string str, timeout timeout_ms = -1);
1560 
1561 public:
1563 
1586 nothing send2(binary bin, timeout timeout_ms = -1);
1587 
1588 public:
1590 
1615 nothing send2(string str, timeout timeout_ms = -1);
1616 
1617 public:
1619 
1644 int sendBinary(string str, timeout timeout_ms = -1);
1645 
1646 public:
1648 
1673 int sendBinary(binary bin, timeout timeout_ms = -1);
1674 
1675 public:
1677 
1699 nothing sendBinary2(string str, timeout timeout_ms = -1);
1700 
1701 public:
1703 
1725 nothing sendBinary2(binary bin, timeout timeout_ms = -1);
1726 
1727 public:
1729 
1750 nothing sendFromInputStream(Qore::InputStream is, softint size = -1, timeout timeout_ms = -1);
1751 
1752 public:
1754 
1777 nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream is, int max_chunk_size = 4096, timeout timeout_ms = -1, *code tcb);
1778 
1779 public:
1781 
1800 nothing sendHTTPChunkedBodyTrailer(*hash<auto> trailer, timeout timeout_ms = -1);
1801 
1802 public:
1804 
1835 nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, *string body, *reference<hash> info, timeout timeout_ms = -1);
1836 
1837 public:
1839 
1868 nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
1869 
1870 public:
1872 
1903 nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
1904 
1905 public:
1907 
1931 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *string body, timeout timeout_ms = -1);
1932 
1933 public:
1935 
1957 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, binary body, timeout timeout_ms = -1);
1958 
1959 public:
1961 
1985 nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, timeout timeout_ms = -1);
1986 
1987 public:
1989 
2012 int sendi1(softint i = 0, timeout timeout_ms = -1);
2013 
2014 public:
2016 
2039 int sendi2(softint i = 0, timeout timeout_ms = -1);
2040 
2041 public:
2043 
2066 int sendi2LSB(softint i = 0, timeout timeout_ms = -1);
2067 
2068 public:
2070 
2093 int sendi4(softint i = 0, timeout timeout_ms = -1);
2094 
2095 public:
2097 
2120 int sendi4LSB(softint i = 0, timeout timeout_ms = -1);
2121 
2122 public:
2124 
2147 int sendi8(softint i = 0, timeout timeout_ms = -1);
2148 
2149 public:
2151 
2174 int sendi8LSB(softint i = 0, timeout timeout_ms = -1);
2175 
2176 public:
2178 
2185 nothing setCertificate(SSLCertificate cert);
2186 
2187 public:
2189 
2196 nothing setCertificate(string cert_pem);
2197 
2198 public:
2200 
2207 nothing setCertificate(binary cert_der);
2208 
2209 public:
2211 
2214 nothing setCharset(string encoding);
2215 
2216 public:
2218 
2220 nothing setEncoding(string encoding);
2221 
2222 public:
2224 
2231 nothing setEventQueue();
2232 
2233 public:
2235 
2246 nothing setEventQueue(Queue queue);
2247 
2248 public:
2250 
2268 int setNoDelay(bool nd = True);
2269 
2270 public:
2272 
2279 nothing setPrivateKey(SSLPrivateKey key);
2280 
2281 public:
2283 
2291 nothing setPrivateKey(string key_pem, *string pass);
2292 
2293 public:
2295 
2302 nothing setPrivateKey(binary key_der);
2303 
2304 public:
2306 
2318 int setRecvTimeout(timeout timeout_ms);
2319 
2320 public:
2322 
2334 int setSendTimeout(timeout timeout_ms);
2335 
2336 public:
2338 
2355  setSslVerifyMode(int mode);
2356 
2357 public:
2359 
2391 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
2392 
2393 public:
2395 
2405 int shutdown();
2406 
2407 public:
2409 
2418 nothing shutdownSSL();
2419 
2420 public:
2422 
2436 nothing upgradeClientToSSL(timeout timeout_ms = -1);
2437 
2438 public:
2440 
2454 nothing upgradeServerToSSL(timeout timeout_ms = -1);
2455 
2456 public:
2458 
2468 *string verifyPeerCertificate();
2469 };
2475 
2477 
2489 
2501 
2510 
2527 
2534 
2536  const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH";
2538  const X509_V_ERR_AKID_SKID_MISMATCH = "X509_V_ERR_AKID_SKID_MISMATCH";
2540  const X509_V_ERR_APPLICATION_VERIFICATION = "X509_V_ERR_APPLICATION_VERIFICATION";
2542  const X509_V_ERR_CERT_CHAIN_TOO_LONG = "X509_V_ERR_CERT_CHAIN_TOO_LONG";
2544  const X509_V_ERR_CERT_HAS_EXPIRED = "X509_V_ERR_CERT_HAS_EXPIRED";
2546  const X509_V_ERR_CERT_NOT_YET_VALID = "X509_V_ERR_CERT_NOT_YET_VALID";
2548  const X509_V_ERR_CERT_REJECTED = "X509_V_ERR_CERT_REJECTED";
2550  const X509_V_ERR_CERT_REVOKED = "X509_V_ERR_CERT_REVOKED";
2552  const X509_V_ERR_CERT_SIGNATURE_FAILURE = "X509_V_ERR_CERT_SIGNATURE_FAILURE";
2554  const X509_V_ERR_CERT_UNTRUSTED = "X509_V_ERR_CERT_UNTRUSTED";
2556  const X509_V_ERR_CRL_HAS_EXPIRED = "X509_V_ERR_CRL_HAS_EXPIRED";
2558  const X509_V_ERR_CRL_NOT_YET_VALID = "X509_V_ERR_CRL_NOT_YET_VALID";
2560  const X509_V_ERR_CRL_SIGNATURE_FAILURE = "X509_V_ERR_CRL_SIGNATURE_FAILURE";
2562  const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT";
2564  const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
2566  const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
2568  const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD";
2570  const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD";
2572  const X509_V_ERR_INVALID_CA = "X509_V_ERR_INVALID_CA";
2574  const X509_V_ERR_INVALID_PURPOSE = "X509_V_ERR_INVALID_PURPOSE";
2576  const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = "X509_V_ERR_KEYUSAGE_NO_CERTSIGN";
2578  const X509_V_ERR_OUT_OF_MEM = "X509_V_ERR_OUT_OF_MEM";
2580  const X509_V_ERR_PATH_LENGTH_EXCEEDED = "X509_V_ERR_PATH_LENGTH_EXCEEDED";
2582  const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN";
2584  const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = "X509_V_ERR_SUBJECT_ISSUER_MISMATCH";
2586  const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY";
2588  const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE";
2590  const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE";
2592  const X509_V_ERR_UNABLE_TO_GET_CRL = "X509_V_ERR_UNABLE_TO_GET_CRL";
2594  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
2596  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY";
2598  const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE";
2600  const X509_V_OK = "X509_V_OK";
2603  "X509_V_OK": "OK",
2604  "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT": "Unable to get issuer certificate",
2605  "X509_V_ERR_UNABLE_TO_GET_CRL": "Unable to get certificate CRL",
2606  "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",
2607  "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE": "Unable to decrypt CRL's signature",
2608  "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY": "Unable to decode issuer public key (SubjectPublicKeyInfo)",
2609  "X509_V_ERR_CERT_SIGNATURE_FAILURE": "Certificate signature failure; the signature of the certificate is invalid",
2610  "X509_V_ERR_CRL_SIGNATURE_FAILURE": "CRL signature failure; the signature of the certificate is invalid",
2611  "X509_V_ERR_CERT_NOT_YET_VALID": "Certificate is not yet valid",
2612  "X509_V_ERR_CERT_HAS_EXPIRED": "Certificate has expired",
2613  "X509_V_ERR_CRL_NOT_YET_VALID": "CRL is not yet valid",
2614  "X509_V_ERR_CRL_HAS_EXPIRED": "CRL has expired",
2615  "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD": "Format error in certificate's notBefore field (invalid time)",
2616  "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD": "Format error in certificate's notAfter field (invalid time)",
2617  "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD": "Format error in CRL's lastUpdate field (invalid time)",
2618  "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD": "Format error in CRL's nextUpdate field (invalid time)",
2619  "X509_V_ERR_OUT_OF_MEM": "Out of memory error",
2620  "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT": "Certificate is self-signed and cannot be found in the trusted list",
2621  "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN": "Self signed certificate in certificate chain",
2622  "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",
2623  "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE": "Unable to verify the first certificate",
2624  "X509_V_ERR_CERT_CHAIN_TOO_LONG": "Certificate chain too long",
2625  "X509_V_ERR_CERT_REVOKED": "Certificate has been revoked",
2626  "X509_V_ERR_INVALID_CA": "Invalid CA certificate",
2627  "X509_V_ERR_PATH_LENGTH_EXCEEDED": "The basicConstraints pathlength parameter has been exceeded",
2628  "X509_V_ERR_INVALID_PURPOSE": "The certificate cannot be used for the specified purpose",
2629  "X509_V_ERR_CERT_UNTRUSTED": "Root CA is not marked as trusted for the specified purpose",
2630  "X509_V_ERR_CERT_REJECTED": "Root CA is marked to reject the specified purpose",
2631  "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",
2632  "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",
2633  "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",
2634  "X509_V_ERR_KEYUSAGE_NO_CERTSIGN": "The keyUsage extension does not permit certificate signing",
2635  "X509_V_ERR_APPLICATION_VERIFICATION": "Verification failure",
2636  );
2638 
2642 
2644  const AFMap = qore(get_network_address_family_map());
2646  const AFStrMap = (
2647  "AF_INET": AF_INET,
2648  "AF_INET6": AF_INET6,
2649  "AF_UNIX": AF_UNIX,
2650  "AF_LOCAL": AF_UNIX,
2651  "AF_UNSPEC": AF_UNSPEC,
2652  );
2654  const AF_INET = AF_INET;
2660  const AF_UNIX = AF_UNIX;
2664 
2669 
2673  const AI_ALL = AI_ALL;
2679 
2684 
2692 
2696 
2700 
2706 
2710 
2718 };
int shutdown()
Ensures that a socket will be closed even if the file descriptor is shared with other processes (for ...
nothing sendHTTPChunkedBodyTrailer(*hash< auto > trailer, timeout timeout_ms=-1)
Sends the trialer of an HTTP message body in chunked transfer encoding.
int recvi1(timeout timeout_ms=-1)
Receives a 1-byte signed integer from the socket.
const SSL_VERIFY_NONE
Do not verify the peer's certificate.
Definition: QC_Socket.dox.h:2508
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.
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:2562
hash< auto > getSocketInfo(bool host_lookup=True)
Returns information about the local socket as a hash.
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 ...
const AF_UNSPEC
unspecified address family
Definition: QC_Socket.dox.h:2662
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...
const SOCK_RAW
raw socket interface, only available to the superuser, untested
Definition: QC_Socket.dox.h:2714
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:2677
const X509_V_ERR_CERT_NOT_YET_VALID
Certificate is not yet valid.
Definition: QC_Socket.dox.h:2546
const X509_V_ERR_OUT_OF_MEM
Out of memory error.
Definition: QC_Socket.dox.h:2578
const X509_V_ERR_PATH_LENGTH_EXCEEDED
The basicConstraints pathlength parameter has been exceeded.
Definition: QC_Socket.dox.h:2580
const AFMap
mapping from Network Address Family Constants to string codes
Definition: QC_Socket.dox.h:2644
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...
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 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 as literal binary...
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:2588
const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
Format error in CRL's lastUpdate field (invalid time)
Definition: QC_Socket.dox.h:2568
const X509_V_ERR_APPLICATION_VERIFICATION
Verification failure.
Definition: QC_Socket.dox.h:2540
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:2673
*SSLCertificate getRemoteCertificate()
Returns any remote certificate captured or NOTHING if there is none.
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.
hash< auto > getPeerInfo(bool host_lookup=True)
Returns a hash of information about the remote end for connected sockets.
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:2602
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:2554
const X509_V_ERR_INVALID_CA
Invalid CA certificate.
Definition: QC_Socket.dox.h:2572
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
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....
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:2682
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's certificate.
Definition: QC_Socket.dox.h:2525
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:2594
*string getSSLCipherVersion()
Returns the version string of the cipher for an encrypted connection or NOTHING if a secure connectio...
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.
const AFStrMap
mapping from network address family string codes to Network Address Family Constants
Definition: QC_Socket.dox.h:2646
const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
Unable to verify the first certificate.
Definition: QC_Socket.dox.h:2598
const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
Unable to decode issuer public key (SubjectPublicKeyInfo)
Definition: QC_Socket.dox.h:2586
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:2558
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:2538
const X509_V_ERR_INVALID_PURPOSE
The certificate cannot be used for the specified purpose.
Definition: QC_Socket.dox.h:2574
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's nextUpdate field (invalid time)
Definition: QC_Socket.dox.h:2570
*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:2499
bool getNoDelay()
Returns the TCP_NODELAY setting for the socket.
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.
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:2592
const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
Format error in certificate's notAfter field (invalid time)
Definition: QC_Socket.dox.h:2564
const X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The keyUsage extension does not permit certificate signing.
Definition: QC_Socket.dox.h:2576
const X509_V_ERR_CERT_REJECTED
Root CA is marked to reject the specified purpose.
Definition: QC_Socket.dox.h:2548
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.
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 ...
This class implements a container for private key data.
Definition: QC_SSLPrivateKey.dox.h:9
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:2656
const AF_INET
IPv4 address family.
Definition: QC_Socket.dox.h:2654
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
This class defines an abstract interface for output streams.
Definition: QC_OutputStream.dox.h:18
const IPPROTO_UDP
for the UDP protocol
Definition: QC_Socket.dox.h:2704
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:2552
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.
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...
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:2596
const X509_V_ERR_CERT_REVOKED
Certificate has been revoked.
Definition: QC_Socket.dox.h:2550
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:2536
const AF_UNIX
UNIX domain address family (UNIX socket files)
Definition: QC_Socket.dox.h:2660
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:2702
const X509_V_OK
Verification OK.
Definition: QC_Socket.dox.h:2600
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:2658
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:2694
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:2584
nothing sendBinary2(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket's encoding,...
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:9
bool captureRemoteCertificates(bool set=True)
Sets the flag for capturing remote X.509 certificates; by default no capture of remote certificates i...
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's notBefore field (invalid time)
Definition: QC_Socket.dox.h:2566
*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:2560
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:2544
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:2675
main Qore-language namespace
Definition: Pseudo_QC_All.dox.h:2
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...
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:18
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.
const SSL_VERIFY_CLIENT_ONCE
Only request a client certificate once in server mode.
Definition: QC_Socket.dox.h:2487
const SOCK_STREAM
for sequenced, reliable, two-way connection-based byte streams (the default)
Definition: QC_Socket.dox.h:2716
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:2671
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's encoding,...
const X509_V_ERR_CERT_CHAIN_TOO_LONG
Certificate chain too long.
Definition: QC_Socket.dox.h:2542
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:2582
const X509_V_ERR_CRL_HAS_EXPIRED
CRL has expired.
Definition: QC_Socket.dox.h:2556
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:2690
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...
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:2712
const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
Unable to decrypt CRL's signature.
Definition: QC_Socket.dox.h:2590
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