Qore Programming Language Reference Manual  1.0.8
QC_Socket.dox.h
1 namespace Qore {
4 
6 struct SocketPollInfo {
8  int events;
11 };
12 }
13 
15 namespace Qore {
17 class Socket {
137 
138 public:
140 
154 Socket accept();
155 
156 public:
158 
174 *Socket accept(timeout timeout_ms);
175 
176 public:
178 
194  acceptAllCertificates(bool accept_all = True);
195 
196 public:
198 
212 Socket acceptSSL();
213 
214 public:
216 
232 *Socket acceptSSL(timeout timeout_ms);
233 
234 public:
236 
256 int bind(string str, softbool reuseaddr = False);
257 
258 public:
260 
274 int bind(int port, softbool reuseaddr = False);
275 
276 public:
278 
306 nothing bindINET(*string iface, *softstring service, softbool reuseaddr = False, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
307 
308 public:
310 
326 nothing bindUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
327 
328 public:
330 
343 bool captureRemoteCertificates(bool set = True);
344 
345 public:
347 
356  clearStats();
357 
358 public:
360 
369 nothing clearWarningQueue();
370 
371 public:
373 
386 int close();
387 
388 public:
390 
415 nothing connect(string target, timeout timeout_ms = -1);
416 
417 public:
419 
443 nothing connectINET(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
444 
445 public:
447 
472 nothing connectINETSSL(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
473 
474 public:
476 
504 nothing connectSSL(string target, timeout timeout_ms = -1);
505 
506 public:
508 
527 nothing connectUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
528 
529 public:
531 
551 nothing connectUNIXSSL(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
552 
553 public:
555 
558  constructor();
559 
560 public:
562 
565  copy();
566 
567 public:
569 
587 
588 public:
590 
596 string getCharset();
597 
598 public:
600 
614 int getConnectionId();
615 
616 public:
618 
623 string getEncoding();
624 
625 public:
627 
639 bool getNoDelay();
640 
641 public:
643 
659 hash<auto> getPeerInfo(bool host_lookup = True);
660 
661 public:
663 
673 int getPort();
674 
675 public:
677 
687 int getRecvTimeout();
688 
689 public:
691 
702 *SSLCertificate getRemoteCertificate();
703 
704 public:
706 
716 *string getSSLCipherName();
717 
718 public:
720 
730 *string getSSLCipherVersion();
731 
732 public:
734 
744 int getSendTimeout();
745 
746 public:
748 
758 int getSocket();
759 
760 public:
762 
778 hash<auto> getSocketInfo(bool host_lookup = True);
779 
780 public:
782 
799 int getSslVerifyMode();
800 
801 public:
803 
824 hash<auto> getUsageInfo();
825 
826 public:
828 
842 bool isDataAvailable(timeout timeout_ms = 0);
843 
844 public:
846 
856 bool isOpen();
857 
858 public:
860 
870 bool isSecure();
871 
872 public:
874 
888 bool isWriteFinished(timeout timeout_ms = 0);
889 
890 public:
892 
905 int listen(int backlog = 20);
906 
907 public:
909 
917 
918 public:
920 
941 hash<auto> readHTTPChunkedBody(timeout timeout_ms = -1);
942 
943 public:
945 
966 hash<auto> readHTTPChunkedBodyBinary(timeout timeout_ms = -1);
967 
968 public:
970 
998  readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms = -1);
999 
1000 public:
1002 
1024 hash<auto> readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms = -1);
1025 
1026 public:
1028 
1056  readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms = -1);
1057 
1058 public:
1060 
1107 hash<auto> readHTTPHeader(timeout timeout_ms = -1, *reference<hash<auto>> info);
1108 
1109 public:
1111 
1134 string readHTTPHeaderString(timeout timeout_ms = -1);
1135 
1136 public:
1138 
1163 string recv(softint size = 0, timeout timeout_ms = -1);
1164 
1165 public:
1167 
1190 binary recvBinary(softint size = 0, timeout timeout_ms = -1);
1191 
1192 public:
1194 
1217 nothing recvToOutputStream(Qore::OutputStream os, softint size = -1, timeout timeout_ms = -1);
1218 
1219 public:
1221 
1243 int recvi1(timeout timeout_ms = -1);
1244 
1245 public:
1247 
1269 int recvi2(timeout timeout_ms = -1);
1270 
1271 public:
1273 
1295 int recvi2LSB(timeout timeout_ms = -1);
1296 
1297 public:
1299 
1321 int recvi4(timeout timeout_ms = -1);
1322 
1323 public:
1325 
1347 int recvi4LSB(timeout timeout_ms = -1);
1348 
1349 public:
1351 
1373 int recvi8(timeout timeout_ms = -1);
1374 
1375 public:
1377 
1399 int recvi8LSB(timeout timeout_ms = -1);
1400 
1401 public:
1403 
1425 int recvu1(timeout timeout_ms = -1);
1426 
1427 public:
1429 
1451 int recvu2(timeout timeout_ms = -1);
1452 
1453 public:
1455 
1477 int recvu2LSB(timeout timeout_ms = -1);
1478 
1479 public:
1481 
1503 int recvu4(timeout timeout_ms = -1);
1504 
1505 public:
1507 
1529 int recvu4LSB(timeout timeout_ms = -1);
1530 
1531 public:
1533 
1559 int send(binary bin, timeout timeout_ms = -1);
1560 
1561 public:
1563 
1591 int send(string str, timeout timeout_ms = -1);
1592 
1593 public:
1595 
1618 nothing send2(binary bin, timeout timeout_ms = -1);
1619 
1620 public:
1622 
1647 nothing send2(string str, timeout timeout_ms = -1);
1648 
1649 public:
1651 
1676 int sendBinary(string str, timeout timeout_ms = -1);
1677 
1678 public:
1680 
1705 int sendBinary(binary bin, timeout timeout_ms = -1);
1706 
1707 public:
1709 
1731 nothing sendBinary2(string str, timeout timeout_ms = -1);
1732 
1733 public:
1735 
1757 nothing sendBinary2(binary bin, timeout timeout_ms = -1);
1758 
1759 public:
1761 
1782 nothing sendFromInputStream(Qore::InputStream input_stream, softint size = -1, timeout timeout_ms = -1);
1783 
1784 public:
1786 
1817 nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream input_stream, int max_chunk_size = 4096, timeout timeout_ms = -1, *code tcb);
1818 
1819 public:
1821 
1844 nothing sendHTTPChunkedBodyTrailer(*hash<auto> trailer, timeout timeout_ms = -1);
1845 
1846 public:
1848 
1883 nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, string body, *reference<hash> info, timeout timeout_ms = -1);
1884 
1885 public:
1887 
1919 nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, *binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
1920 
1921 public:
1923 
1951 nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
1952 
1953 public:
1955 
1979 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, string body, timeout timeout_ms = -1);
1980 
1981 public:
1983 
2021 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, string body, *reference<hash<auto>> info, timeout timeout_ms = -1);
2022 
2023 public:
2025 
2054 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *binary body, timeout timeout_ms = -1);
2055 
2056 public:
2058 
2092 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
2093 
2094 public:
2096 
2138 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);
2139 
2140 public:
2142 
2177 nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, timeout timeout_ms = -1);
2178 
2179 public:
2181 
2219 nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
2220 
2221 public:
2223 
2246 int sendi1(softint i = 0, timeout timeout_ms = -1);
2247 
2248 public:
2250 
2273 int sendi2(softint i = 0, timeout timeout_ms = -1);
2274 
2275 public:
2277 
2300 int sendi2LSB(softint i = 0, timeout timeout_ms = -1);
2301 
2302 public:
2304 
2327 int sendi4(softint i = 0, timeout timeout_ms = -1);
2328 
2329 public:
2331 
2354 int sendi4LSB(softint i = 0, timeout timeout_ms = -1);
2355 
2356 public:
2358 
2381 int sendi8(softint i = 0, timeout timeout_ms = -1);
2382 
2383 public:
2385 
2408 int sendi8LSB(softint i = 0, timeout timeout_ms = -1);
2409 
2410 public:
2412 
2419 nothing setCertificate(SSLCertificate cert);
2420 
2421 public:
2423 
2430 nothing setCertificate(string cert_pem);
2431 
2432 public:
2434 
2441 nothing setCertificate(binary cert_der);
2442 
2443 public:
2445 
2448 nothing setCharset(string encoding);
2449 
2450 public:
2452 
2454 nothing setEncoding(string encoding);
2455 
2456 public:
2458 
2465 nothing setEventQueue();
2466 
2467 public:
2469 
2485 nothing setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data);
2486 
2487 public:
2489 
2507 int setNoDelay(bool nd = True);
2508 
2509 public:
2511 
2518 nothing setPrivateKey(SSLPrivateKey key);
2519 
2520 public:
2522 
2530 nothing setPrivateKey(string key_pem, *string pass);
2531 
2532 public:
2534 
2541 nothing setPrivateKey(binary key_der);
2542 
2543 public:
2545 
2557 int setRecvTimeout(timeout timeout_ms);
2558 
2559 public:
2561 
2573 int setSendTimeout(timeout timeout_ms);
2574 
2575 public:
2577 
2594  setSslVerifyMode(int mode);
2595 
2596 public:
2598 
2630 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
2631 
2632 public:
2634 
2644 int shutdown();
2645 
2646 public:
2648 
2657 nothing shutdownSSL();
2658 
2659 public:
2661 
2675 nothing upgradeClientToSSL(timeout timeout_ms = -1);
2676 
2677 public:
2679 
2693 nothing upgradeServerToSSL(timeout timeout_ms = -1);
2694 
2695 public:
2697 
2707 *string verifyPeerCertificate();
2708 
2709 public:
2711 
2742 static list<hash<SocketPollInfo>> poll(list<hash<SocketPollInfo>> items, timeout timeout_ms);
2743 };
2746 
2748  const SOCK_POLLERR = SOCK_POLLERR;
2759 
2761 
2774 
2786 
2795 
2818 
2820  const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH";
2823  const X509_V_ERR_AKID_SKID_MISMATCH = "X509_V_ERR_AKID_SKID_MISMATCH";
2825  const X509_V_ERR_APPLICATION_VERIFICATION = "X509_V_ERR_APPLICATION_VERIFICATION";
2827  const X509_V_ERR_CERT_CHAIN_TOO_LONG = "X509_V_ERR_CERT_CHAIN_TOO_LONG";
2829  const X509_V_ERR_CERT_HAS_EXPIRED = "X509_V_ERR_CERT_HAS_EXPIRED";
2831  const X509_V_ERR_CERT_NOT_YET_VALID = "X509_V_ERR_CERT_NOT_YET_VALID";
2833  const X509_V_ERR_CERT_REJECTED = "X509_V_ERR_CERT_REJECTED";
2835  const X509_V_ERR_CERT_REVOKED = "X509_V_ERR_CERT_REVOKED";
2837  const X509_V_ERR_CERT_SIGNATURE_FAILURE = "X509_V_ERR_CERT_SIGNATURE_FAILURE";
2839  const X509_V_ERR_CERT_UNTRUSTED = "X509_V_ERR_CERT_UNTRUSTED";
2841  const X509_V_ERR_CRL_HAS_EXPIRED = "X509_V_ERR_CRL_HAS_EXPIRED";
2843  const X509_V_ERR_CRL_NOT_YET_VALID = "X509_V_ERR_CRL_NOT_YET_VALID";
2845  const X509_V_ERR_CRL_SIGNATURE_FAILURE = "X509_V_ERR_CRL_SIGNATURE_FAILURE";
2847  const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT";
2849  const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
2851  const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
2853  const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD";
2855  const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD";
2857  const X509_V_ERR_INVALID_CA = "X509_V_ERR_INVALID_CA";
2859  const X509_V_ERR_INVALID_PURPOSE = "X509_V_ERR_INVALID_PURPOSE";
2861  const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = "X509_V_ERR_KEYUSAGE_NO_CERTSIGN";
2863  const X509_V_ERR_OUT_OF_MEM = "X509_V_ERR_OUT_OF_MEM";
2865  const X509_V_ERR_PATH_LENGTH_EXCEEDED = "X509_V_ERR_PATH_LENGTH_EXCEEDED";
2867  const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN";
2869  const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = "X509_V_ERR_SUBJECT_ISSUER_MISMATCH";
2871  const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY";
2873  const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE";
2875  const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE";
2877  const X509_V_ERR_UNABLE_TO_GET_CRL = "X509_V_ERR_UNABLE_TO_GET_CRL";
2879  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
2881  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY";
2883  const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE";
2885  const X509_V_OK = "X509_V_OK";
2888  "X509_V_OK": "OK",
2889  "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT": "Unable to get issuer certificate",
2890  "X509_V_ERR_UNABLE_TO_GET_CRL": "Unable to get certificate CRL",
2891  "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",
2892  "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE": "Unable to decrypt CRL's signature",
2893  "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY": "Unable to decode issuer public key (SubjectPublicKeyInfo)",
2894  "X509_V_ERR_CERT_SIGNATURE_FAILURE": "Certificate signature failure; the signature of the certificate is invalid",
2895  "X509_V_ERR_CRL_SIGNATURE_FAILURE": "CRL signature failure; the signature of the certificate is invalid",
2896  "X509_V_ERR_CERT_NOT_YET_VALID": "Certificate is not yet valid",
2897  "X509_V_ERR_CERT_HAS_EXPIRED": "Certificate has expired",
2898  "X509_V_ERR_CRL_NOT_YET_VALID": "CRL is not yet valid",
2899  "X509_V_ERR_CRL_HAS_EXPIRED": "CRL has expired",
2900  "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD": "Format error in certificate's notBefore field (invalid time)",
2901  "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD": "Format error in certificate's notAfter field (invalid time)",
2902  "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD": "Format error in CRL's lastUpdate field (invalid time)",
2903  "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD": "Format error in CRL's nextUpdate field (invalid time)",
2904  "X509_V_ERR_OUT_OF_MEM": "Out of memory error",
2905  "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT": "Certificate is self-signed and cannot be found in the trusted list",
2906  "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN": "Self signed certificate in certificate chain",
2907  "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",
2908  "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE": "Unable to verify the first certificate",
2909  "X509_V_ERR_CERT_CHAIN_TOO_LONG": "Certificate chain too long",
2910  "X509_V_ERR_CERT_REVOKED": "Certificate has been revoked",
2911  "X509_V_ERR_INVALID_CA": "Invalid CA certificate",
2912  "X509_V_ERR_PATH_LENGTH_EXCEEDED": "The basicConstraints pathlength parameter has been exceeded",
2913  "X509_V_ERR_INVALID_PURPOSE": "The certificate cannot be used for the specified purpose",
2914  "X509_V_ERR_CERT_UNTRUSTED": "Root CA is not marked as trusted for the specified purpose",
2915  "X509_V_ERR_CERT_REJECTED": "Root CA is marked to reject the specified purpose",
2916  "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",
2917  "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",
2918  "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",
2919  "X509_V_ERR_KEYUSAGE_NO_CERTSIGN": "The keyUsage extension does not permit certificate signing",
2920  "X509_V_ERR_APPLICATION_VERIFICATION": "Verification failure",
2921  );
2926 
2928  const AFMap = qore(get_network_address_family_map());
2931  const AFStrMap = (
2932  "AF_INET": AF_INET,
2933  "AF_INET6": AF_INET6,
2934  "AF_UNIX": AF_UNIX,
2935  "AF_LOCAL": AF_UNIX,
2936  "AF_UNSPEC": AF_UNSPEC,
2937  );
2939  const AF_INET = AF_INET;
2945  const AF_UNIX = AF_UNIX;
2953 
2955  const AI_ADDRCONFIG = AI_ADDRCONFIG;
2958  const AI_ALL = AI_ALL;
2964 
2969 
2977 
2984 
2986  const IPPROTO_TCP = IPPROTO_TCP;
2994 
2996  const SOCK_DGRAM = SOCK_DGRAM;
3003 }
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&#39;s certificate.
Definition: QC_Socket.dox.h:2793
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:2847
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:2947
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:2999
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:2962
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.
const X509_V_ERR_CERT_NOT_YET_VALID
Certificate is not yet valid.
Definition: QC_Socket.dox.h:2831
const X509_V_ERR_OUT_OF_MEM
Out of memory error.
Definition: QC_Socket.dox.h:2863
const X509_V_ERR_PATH_LENGTH_EXCEEDED
The basicConstraints pathlength parameter has been exceeded.
Definition: QC_Socket.dox.h:2865
const AFMap
mapping from Network Address Family Constants to string codes
Definition: QC_Socket.dox.h:2929
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 to send with chun...
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:2873
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:2853
const X509_V_ERR_APPLICATION_VERIFICATION
Verification failure.
Definition: QC_Socket.dox.h:2825
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:2958
*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:136
const X509_VerificationReasons
maps from varification strings to verification code descriptions
Definition: QC_Socket.dox.h:2887
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:2839
const X509_V_ERR_INVALID_CA
Invalid CA certificate.
Definition: QC_Socket.dox.h:2857
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.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:98
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:2967
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...
Socket socket
the socket to monitor
Definition: QC_Socket.dox.h:10
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:2810
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:2879
*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.
const SOCK_POLLOUT
(input and output) for polling for write events
Definition: QC_Socket.dox.h:2753
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:96
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...
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:2931
const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
Unable to verify the first certificate.
Definition: QC_Socket.dox.h:2883
const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
Unable to decode issuer public key (SubjectPublicKeyInfo)
Definition: QC_Socket.dox.h:2871
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:2843
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:2823
const X509_V_ERR_INVALID_PURPOSE
The certificate cannot be used for the specified purpose.
Definition: QC_Socket.dox.h:2859
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:2855
*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:2784
bool getNoDelay()
Returns the TCP_NODELAY setting for the socket.
list< auto > list(...)
Returns a list of the arguments passed at the top level.
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:2877
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:2849
const X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The keyUsage extension does not permit certificate signing.
Definition: QC_Socket.dox.h:2861
const X509_V_ERR_CERT_REJECTED
Root CA is marked to reject the specified purpose.
Definition: QC_Socket.dox.h:2833
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 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:2941
const AF_INET
IPv4 address family.
Definition: QC_Socket.dox.h:2939
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
const SOCK_POLLERR
(output only) indicates that the socket or connection is closed
Definition: QC_Socket.dox.h:2749
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:2989
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:2837
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.
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:2881
const X509_V_ERR_CERT_REVOKED
Certificate has been revoked.
Definition: QC_Socket.dox.h:2835
int events
Socket poll type; see Socket Poll Constants for possible values to be combined with binary or; on inp...
Definition: QC_Socket.dox.h:8
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:2821
const AF_UNIX
UNIX domain address family (UNIX socket files)
Definition: QC_Socket.dox.h:2945
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:2987
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 ...
const X509_V_OK
Verification OK.
Definition: QC_Socket.dox.h:2885
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:2943
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:2979
int getConnectionId()
Returns an integer connection ID that is incremented every time the socket is disconnected.
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:2869
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.
Socket poll info hash.
Definition: QC_Socket.dox.h:6
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...
bool captureRemoteCertificates(bool set=True)
Sets the flag for capturing remote X.509 certificates; by default no capture of remote certificates i...
Queue objects provide a blocking, thread-safe message-passing object to Qore programs ...
Definition: QC_Queue.dox.h:22
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:2851
*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...
static list< hash< SocketPollInfo > > poll(list< hash< SocketPollInfo >> items, timeout timeout_ms)
polls multiple sockets and returns all sockets with events
const X509_V_ERR_CRL_SIGNATURE_FAILURE
CRL signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:2845
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:2829
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:2960
main Qore-language namespace
Definition: Pseudo_QC_All.dox.h:3
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:19
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:2772
const SOCK_STREAM
for sequenced, reliable, two-way connection-based byte streams (the default)
Definition: QC_Socket.dox.h:3001
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:2956
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:2827
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...
const SOCK_POLLIN
(input and output) for polling for read events
Definition: QC_Socket.dox.h:2751
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:2867
const X509_V_ERR_CRL_HAS_EXPIRED
CRL has expired.
Definition: QC_Socket.dox.h:2841
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:2975
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:2997
const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
Unable to decrypt CRL&#39;s signature.
Definition: QC_Socket.dox.h:2875
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
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...