Qore Programming Language Reference Manual  1.11.0
QC_Socket.dox.h
1 namespace Qore {
4 
6 struct SocketPollInfo {
8  int events;
11 };
12 }
13 
15 namespace Qore {
17 class Socket {
151 
152 public:
154 
170 
171 public:
173 
189 *Socket accept(timeout timeout_ms);
190 
191 public:
193 
209  acceptAllCertificates(bool accept_all = True);
210 
211 public:
213 
231 
232 public:
234 
250 *Socket acceptSSL(timeout timeout_ms);
251 
252 public:
254 
274 int bind(string str, softbool reuseaddr = False);
275 
276 public:
278 
292 int bind(int port, softbool reuseaddr = False);
293 
294 public:
296 
324 nothing bindINET(*string iface, *softstring service, softbool reuseaddr = False, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
325 
326 public:
328 
344 nothing bindUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
345 
346 public:
348 
362 
363 public:
365 
375 
376 public:
378 
388 
389 public:
391 
404 int close();
405 
406 public:
408 
446 nothing connect(string target, timeout timeout_ms = -1);
447 
448 public:
450 
474 nothing connectINET(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
475 
476 public:
478 
503 nothing connectINETSSL(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
504 
505 public:
507 
535 nothing connectSSL(string target, timeout timeout_ms = -1);
536 
537 public:
539 
558 nothing connectUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
559 
560 public:
562 
582 nothing connectUNIXSSL(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
583 
584 public:
586 
590 
591 public:
593 
596  copy();
597 
598 public:
600 
618 
619 public:
621 
627 string getCharset();
628 
629 public:
631 
646 
647 public:
649 
654 string getEncoding();
655 
656 public:
658 
670 bool getNoDelay();
671 
672 public:
674 
690 hash<auto> getPeerInfo(bool host_lookup = True);
691 
692 public:
694 
704 int getPort();
705 
706 public:
708 
719 
720 public:
722 
734 
735 public:
737 
748 
749 public:
751 
762 
763 public:
765 
776 
777 public:
779 
789 int getSocket();
790 
791 public:
793 
809 hash<auto> getSocketInfo(bool host_lookup = True);
810 
811 public:
813 
831 
832 public:
834 
855 hash<auto> getUsageInfo();
856 
857 public:
859 
873 bool isDataAvailable(timeout timeout_ms = 0);
874 
875 public:
877 
887 bool isOpen();
888 
889 public:
891 
901 bool isSecure();
902 
903 public:
905 
919 bool isWriteFinished(timeout timeout_ms = 0);
920 
921 public:
923 
936 int listen(int backlog = 20);
937 
938 public:
940 
948 
949 public:
951 
972 hash<auto> readHTTPChunkedBody(timeout timeout_ms = -1);
973 
974 public:
976 
997 hash<auto> readHTTPChunkedBodyBinary(timeout timeout_ms = -1);
998 
999 public:
1001 
1029  readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms = -1);
1030 
1031 public:
1033 
1055 hash<auto> readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms = -1);
1056 
1057 public:
1059 
1087  readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms = -1);
1088 
1089 public:
1091 
1138 hash<auto> readHTTPHeader(timeout timeout_ms = -1, *reference<hash<auto>> info);
1139 
1140 public:
1142 
1165 string readHTTPHeaderString(timeout timeout_ms = -1);
1166 
1167 public:
1169 
1194 string recv(softint size = 0, timeout timeout_ms = -1);
1195 
1196 public:
1198 
1221 binary recvBinary(softint size = 0, timeout timeout_ms = -1);
1222 
1223 public:
1225 
1248 nothing recvToOutputStream(Qore::OutputStream os, softint size = -1, timeout timeout_ms = -1);
1249 
1250 public:
1252 
1274 int recvi1(timeout timeout_ms = -1);
1275 
1276 public:
1278 
1300 int recvi2(timeout timeout_ms = -1);
1301 
1302 public:
1304 
1326 int recvi2LSB(timeout timeout_ms = -1);
1327 
1328 public:
1330 
1357 int recvi4(timeout timeout_ms = -1);
1358 
1359 public:
1361 
1383 int recvi4LSB(timeout timeout_ms = -1);
1384 
1385 public:
1387 
1409 int recvi8(timeout timeout_ms = -1);
1410 
1411 public:
1413 
1435 int recvi8LSB(timeout timeout_ms = -1);
1436 
1437 public:
1439 
1461 int recvu1(timeout timeout_ms = -1);
1462 
1463 public:
1465 
1487 int recvu2(timeout timeout_ms = -1);
1488 
1489 public:
1491 
1513 int recvu2LSB(timeout timeout_ms = -1);
1514 
1515 public:
1517 
1539 int recvu4(timeout timeout_ms = -1);
1540 
1541 public:
1543 
1565 int recvu4LSB(timeout timeout_ms = -1);
1566 
1567 public:
1569 
1595 int send(binary bin, timeout timeout_ms = -1);
1596 
1597 public:
1599 
1627 int send(string str, timeout timeout_ms = -1);
1628 
1629 public:
1631 
1654 nothing send2(binary bin, timeout timeout_ms = -1);
1655 
1656 public:
1658 
1683 nothing send2(string str, timeout timeout_ms = -1);
1684 
1685 public:
1687 
1712 int sendBinary(string str, timeout timeout_ms = -1);
1713 
1714 public:
1716 
1741 int sendBinary(binary bin, timeout timeout_ms = -1);
1742 
1743 public:
1745 
1767 nothing sendBinary2(string str, timeout timeout_ms = -1);
1768 
1769 public:
1771 
1793 nothing sendBinary2(binary bin, timeout timeout_ms = -1);
1794 
1795 public:
1797 
1818 nothing sendFromInputStream(Qore::InputStream input_stream, softint size = -1, timeout timeout_ms = -1);
1819 
1820 public:
1822 
1853 nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream input_stream, int max_chunk_size = 4096, timeout timeout_ms = -1, *code tcb);
1854 
1855 public:
1857 
1880 nothing sendHTTPChunkedBodyTrailer(*hash<auto> trailer, timeout timeout_ms = -1);
1881 
1882 public:
1884 
1919 nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, string body, *reference<hash> info, timeout timeout_ms = -1);
1920 
1921 public:
1923 
1955 nothing sendHTTPMessage(string method, string path, string http_version, hash<auto> headers, *binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
1956 
1957 public:
1959 
1987 nothing sendHTTPMessageWithCallback(code scb, string method, string path, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
1988 
1989 public:
1991 
2015 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, string body, timeout timeout_ms = -1);
2016 
2017 public:
2019 
2057 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, string body, *reference<hash<auto>> info, timeout timeout_ms = -1);
2058 
2059 public:
2061 
2090 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *binary body, timeout timeout_ms = -1);
2091 
2092 public:
2094 
2128 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash<auto> headers, *binary body, *reference<hash<auto>> info, timeout timeout_ms = -1);
2129 
2130 public:
2132 
2174 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);
2175 
2176 public:
2178 
2213 nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, timeout timeout_ms = -1);
2214 
2215 public:
2217 
2255 nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash<auto> headers, *reference<hash<auto>> info, timeout timeout_ms = -1);
2256 
2257 public:
2259 
2282 int sendi1(softint i = 0, timeout timeout_ms = -1);
2283 
2284 public:
2286 
2309 int sendi2(softint i = 0, timeout timeout_ms = -1);
2310 
2311 public:
2313 
2336 int sendi2LSB(softint i = 0, timeout timeout_ms = -1);
2337 
2338 public:
2340 
2363 int sendi4(softint i = 0, timeout timeout_ms = -1);
2364 
2365 public:
2367 
2390 int sendi4LSB(softint i = 0, timeout timeout_ms = -1);
2391 
2392 public:
2394 
2417 int sendi8(softint i = 0, timeout timeout_ms = -1);
2418 
2419 public:
2421 
2444 int sendi8LSB(softint i = 0, timeout timeout_ms = -1);
2445 
2446 public:
2448 
2456 
2457 public:
2459 
2466 nothing setCertificate(string cert_pem);
2467 
2468 public:
2470 
2477 nothing setCertificate(binary cert_der);
2478 
2479 public:
2481 
2492 
2493 public:
2495 
2498 nothing setCharset(string encoding);
2499 
2500 public:
2502 
2504 nothing setEncoding(string encoding);
2505 
2506 public:
2508 
2515 nothing setEventQueue();
2516 
2517 public:
2519 
2535 nothing setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data);
2536 
2537 public:
2539 
2557 int setNoDelay(bool nd = True);
2558 
2559 public:
2561 
2569 
2570 public:
2572 
2580 nothing setPrivateKey(string key_pem, *string pass);
2581 
2582 public:
2584 
2591 nothing setPrivateKey(binary key_der);
2592 
2593 public:
2595 
2607 int setRecvTimeout(timeout timeout_ms);
2608 
2609 public:
2611 
2623 int setSendTimeout(timeout timeout_ms);
2624 
2625 public:
2627 
2644  setSslVerifyMode(int mode);
2645 
2646 public:
2648 
2680 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
2681 
2682 public:
2684 
2694 int shutdown();
2695 
2696 public:
2698 
2707 nothing shutdownSSL();
2708 
2709 public:
2711 
2725 nothing upgradeClientToSSL(timeout timeout_ms = -1);
2726 
2727 public:
2729 
2743 nothing upgradeServerToSSL(timeout timeout_ms = -1);
2744 
2745 public:
2747 
2758 
2759 public:
2761 
2792 static list<hash<SocketPollInfo>> poll(list<hash<SocketPollInfo>> items, timeout timeout_ms);
2793 };
2796 
2809 
2812 
2824 
2836 
2845 
2868 
2871  const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH";
2873  const X509_V_ERR_AKID_SKID_MISMATCH = "X509_V_ERR_AKID_SKID_MISMATCH";
2875  const X509_V_ERR_APPLICATION_VERIFICATION = "X509_V_ERR_APPLICATION_VERIFICATION";
2877  const X509_V_ERR_CERT_CHAIN_TOO_LONG = "X509_V_ERR_CERT_CHAIN_TOO_LONG";
2879  const X509_V_ERR_CERT_HAS_EXPIRED = "X509_V_ERR_CERT_HAS_EXPIRED";
2881  const X509_V_ERR_CERT_NOT_YET_VALID = "X509_V_ERR_CERT_NOT_YET_VALID";
2883  const X509_V_ERR_CERT_REJECTED = "X509_V_ERR_CERT_REJECTED";
2885  const X509_V_ERR_CERT_REVOKED = "X509_V_ERR_CERT_REVOKED";
2887  const X509_V_ERR_CERT_SIGNATURE_FAILURE = "X509_V_ERR_CERT_SIGNATURE_FAILURE";
2889  const X509_V_ERR_CERT_UNTRUSTED = "X509_V_ERR_CERT_UNTRUSTED";
2891  const X509_V_ERR_CRL_HAS_EXPIRED = "X509_V_ERR_CRL_HAS_EXPIRED";
2893  const X509_V_ERR_CRL_NOT_YET_VALID = "X509_V_ERR_CRL_NOT_YET_VALID";
2895  const X509_V_ERR_CRL_SIGNATURE_FAILURE = "X509_V_ERR_CRL_SIGNATURE_FAILURE";
2897  const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT";
2899  const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
2901  const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
2903  const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD";
2905  const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD";
2907  const X509_V_ERR_INVALID_CA = "X509_V_ERR_INVALID_CA";
2909  const X509_V_ERR_INVALID_PURPOSE = "X509_V_ERR_INVALID_PURPOSE";
2911  const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = "X509_V_ERR_KEYUSAGE_NO_CERTSIGN";
2913  const X509_V_ERR_OUT_OF_MEM = "X509_V_ERR_OUT_OF_MEM";
2915  const X509_V_ERR_PATH_LENGTH_EXCEEDED = "X509_V_ERR_PATH_LENGTH_EXCEEDED";
2917  const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN";
2919  const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = "X509_V_ERR_SUBJECT_ISSUER_MISMATCH";
2921  const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY";
2923  const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE";
2925  const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE";
2927  const X509_V_ERR_UNABLE_TO_GET_CRL = "X509_V_ERR_UNABLE_TO_GET_CRL";
2929  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
2931  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY";
2933  const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE";
2935  const X509_V_OK = "X509_V_OK";
2938  "X509_V_OK": "OK",
2939  "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT": "Unable to get issuer certificate",
2940  "X509_V_ERR_UNABLE_TO_GET_CRL": "Unable to get certificate CRL",
2941  "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",
2942  "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE": "Unable to decrypt CRL's signature",
2943  "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY": "Unable to decode issuer public key (SubjectPublicKeyInfo)",
2944  "X509_V_ERR_CERT_SIGNATURE_FAILURE": "Certificate signature failure; the signature of the certificate is invalid",
2945  "X509_V_ERR_CRL_SIGNATURE_FAILURE": "CRL signature failure; the signature of the certificate is invalid",
2946  "X509_V_ERR_CERT_NOT_YET_VALID": "Certificate is not yet valid",
2947  "X509_V_ERR_CERT_HAS_EXPIRED": "Certificate has expired",
2948  "X509_V_ERR_CRL_NOT_YET_VALID": "CRL is not yet valid",
2949  "X509_V_ERR_CRL_HAS_EXPIRED": "CRL has expired",
2950  "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD": "Format error in certificate's notBefore field (invalid time)",
2951  "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD": "Format error in certificate's notAfter field (invalid time)",
2952  "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD": "Format error in CRL's lastUpdate field (invalid time)",
2953  "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD": "Format error in CRL's nextUpdate field (invalid time)",
2954  "X509_V_ERR_OUT_OF_MEM": "Out of memory error",
2955  "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT": "Certificate is self-signed and cannot be found in the trusted list",
2956  "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN": "Self signed certificate in certificate chain",
2957  "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",
2958  "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE": "Unable to verify the first certificate",
2959  "X509_V_ERR_CERT_CHAIN_TOO_LONG": "Certificate chain too long",
2960  "X509_V_ERR_CERT_REVOKED": "Certificate has been revoked",
2961  "X509_V_ERR_INVALID_CA": "Invalid CA certificate",
2962  "X509_V_ERR_PATH_LENGTH_EXCEEDED": "The basicConstraints pathlength parameter has been exceeded",
2963  "X509_V_ERR_INVALID_PURPOSE": "The certificate cannot be used for the specified purpose",
2964  "X509_V_ERR_CERT_UNTRUSTED": "Root CA is not marked as trusted for the specified purpose",
2965  "X509_V_ERR_CERT_REJECTED": "Root CA is marked to reject the specified purpose",
2966  "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",
2967  "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",
2968  "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",
2969  "X509_V_ERR_KEYUSAGE_NO_CERTSIGN": "The keyUsage extension does not permit certificate signing",
2970  "X509_V_ERR_APPLICATION_VERIFICATION": "Verification failure",
2971 );
2976 
2979  const AFMap = qore(get_network_address_family_map());
2981  const AFStrMap = (
2982  "AF_INET": AF_INET,
2983  "AF_INET6": AF_INET6,
2984  "AF_UNIX": AF_UNIX,
2985  "AF_LOCAL": AF_UNIX,
2986  "AF_UNSPEC": AF_UNSPEC,
2987 );
2989  const AF_INET = AF_INET;
2995  const AF_UNIX = AF_UNIX;
3003 
3008  const AI_ALL = AI_ALL;
3014 
3019 
3027 
3034 
3044 
3053 }
This class defines an abstract interface for input streams.
Definition: QC_InputStream.dox.h:19
This class defines an abstract interface for output streams.
Definition: QC_OutputStream.dox.h:18
SSLCertificate objects allow Qore code to work with X.509 certificate data.
Definition: QC_SSLCertificate.dox.h:10
This class implements a container for private key data.
Definition: QC_SSLPrivateKey.dox.h:10
The Socket class allows Qore programs safe access to network sockets.
Definition: QC_Socket.dox.h:150
int sendi2LSB(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in little-endian format over the socket.
nothing send2(string str, timeout timeout_ms=-1)
Sends string data over the socket; string data is converted to the socket's encoding if necessary; if...
int getSendTimeout()
Returns the send timeout socket option value as an integer in milliseconds.
int sendBinary(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
bool getAcceptAllCertificates()
returns the current value of the "accept all certificates" flag
int sendi1(softint i=0, timeout timeout_ms=-1)
Sends a 1-byte integer over the socket.
int sendi8LSB(softint i=0, timeout timeout_ms=-1)
Sends an 8-byte (64-bit) integer in little-endian format over the socket.
bool pendingHttpChunkedBody()
returns True if the socket is still connected, and a HTTP header was read indicating chunked transfer...
bool captureRemoteCertificates(bool set=True)
Sets the flag for capturing remote X.509 certificates; by default no capture of remote certificates i...
bool isOpen()
Returns True if the socket is open.
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...
int recvu2(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in big-endian format (network byte order) from the socket...
int getSocket()
Returns the socket file descriptor number.
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 ...
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
int setRecvTimeout(timeout timeout_ms)
sets the receive timeout as a socket option
hash< auto > getSocketInfo(bool host_lookup=True)
Returns information about the local socket as a hash.
Socket accept()
Accepts connections on a listening socket.
bool getNoDelay()
Returns the TCP_NODELAY setting for the socket.
nothing connectSSL(string target, timeout timeout_ms=-1)
Connects to a remote socket and attempts to establish a TLS/SSL connection; accepts an optional timeo...
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, string body, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and an optional message body.
nothing setCertificate(binary cert_der)
Sets the X.509 certificate to use for negotiating encrypted connections from the DER-encoded binary o...
nothing sendFromInputStream(Qore::InputStream input_stream, softint size=-1, timeout timeout_ms=-1)
Reads data from an InputStream and sends the bytes over the socket.
int close()
Closes an open socket.
*string getSSLCipherName()
Returns the name of the cipher for an encrypted connection or NOTHING if a secure connection has not ...
int listen(int backlog=20)
Listens for connections on a bound socket; sets the socket in a listening state.
nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash< auto > headers, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body to send with chun...
*Socket accept(timeout timeout_ms)
Accepts connections on a listening socket (see Socket::listen()) accepting a timeout value with a mil...
*string getSSLCipherVersion()
Returns the version string of the cipher for an encrypted connection or NOTHING if a secure connectio...
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
int recvu4LSB(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) unsigned integer in little-endian format from the socket.
int recvi2(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in big-endian format (network byte order) from the socket.
bool isWriteFinished(timeout timeout_ms=0)
Returns True or False depending on whether all the data has been written to the socket.
nothing connectUNIXSSL(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given UNIX domain socket file and attempts to establish a TLS/SSL connection.
nothing setCertificateAndPrivateKey(SSLCertificate cert, SSLPrivateKey key)
Sets the X.509 certificate and private key in one atomic operation to use for negotiating encrypted c...
*string verifyPeerCertificate()
Returns a string code giving the result of verifying the remote certificate or NOTHING if an encrypte...
int recvi4LSB(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) signed integer in little-endian format from the socket.
bool isSecure()
Returns True if the connection is a secure TLS/SSL connection.
nothing sendBinary2(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket's encoding,...
*Socket acceptSSL(timeout timeout_ms)
Accepts connections on a listening socket and attempts to negotiate a TLS/SSL connection accepting a ...
int sendi4LSB(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in little-endian format over the socket.
int getConnectionId()
Returns an integer connection ID that is incremented every time the socket is disconnected.
nothing connectINETSSL(string host, softstring service, timeout timeout_ms=-1, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given host and port and attempts to establish a TLS/SSL connection; accepts an option...
*SSLCertificate getRemoteCertificate()
Returns any remote certificate captured or NOTHING if there is none.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, Qore::InputStream input_stream, int max_chunk_size=4096, *reference< hash< auto >> info, timeout timeout_ms=-1, *code tcb)
Sends an HTTP response with user-defined headers and a message body from an input stream in chunked t...
int getSslVerifyMode()
returns the current SSL verification mode
nothing connectINET(string host, softstring service, timeout timeout_ms=-1, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given host and port with an optional timeout value with a millisecond resolution.
int recvi8LSB(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in little-endian format from the socket.
nothing connect(string target, timeout timeout_ms=-1)
Connects to a remote port (if the string has a format "host:port") or UNIX domain socket file with an...
int bind(int port, softbool reuseaddr=False)
Opens and binds the socket to an INET port on all interfaces.
nothing setPrivateKey(string key_pem, *string pass)
Sets the private key to use for negotiating encrypted connections along with the X....
nothing upgradeServerToSSL(timeout timeout_ms=-1)
Upgrades a server socket connection to a TLS/SSL connection.
int bind(string str, softbool reuseaddr=False)
Opens and binds the socket to a port, interface and port (if the bind_to string has a format "host:po...
nothing sendBinary2(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
int sendi8(softint i=0, timeout timeout_ms=-1)
Sends an 8-byte (64-bit) integer in big-endian format (network byte order) over the socket.
nothing bindINET(*string iface, *softstring service, softbool reuseaddr=False, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Opens and binds the socket to the given IPv4 or IPv6 interface (or if no interface is given,...
int sendi4(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in big-endian format (network byte order) over the socket.
nothing recvToOutputStream(Qore::OutputStream os, softint size=-1, timeout timeout_ms=-1)
Receives data from the socket and writes the bytes to an OutputStream.
nothing setCertificate(SSLCertificate cert)
Sets the X.509 certificate to use for negotiating encrypted connections.
readHTTPChunkedBodyWithCallback(code rcb, timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
int recvi1(timeout timeout_ms=-1)
Receives a 1-byte signed integer from the socket.
int getRecvTimeout()
Returns the receive timeout socket option value as an integer in milliseconds.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, string body, *reference< hash< auto >> info, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and an optional message body.
nothing setCertificate(string cert_pem)
Sets the X.509 certificate to use for negotiating encrypted connections from the PEM-encoded string r...
clearStats()
Clears performance statistics.
int recvu2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in little-endian format from the socket.
binary recvBinary(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a binary object.
int send(string str, timeout timeout_ms=-1)
Sends string data over the socket; string data is converted to the socket's encoding if necessary; if...
readHTTPChunkedBodyBinaryWithCallback(code rcb, timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
static list< hash< SocketPollInfo > > poll(list< hash< SocketPollInfo >> items, timeout timeout_ms)
polls multiple sockets and returns all sockets with events
acceptAllCertificates(bool accept_all=True)
with peer verification enabled, all certificates are accepted regardless of the validity of the Certi...
int send(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
nothing setPrivateKey(binary key_der)
Sets the private key to use for negotiating encrypted connections along with the X....
hash< auto > getPeerInfo(bool host_lookup=True)
Returns a hash of information about the remote end for connected sockets.
int setSendTimeout(timeout timeout_ms)
sets the send timeout as a socket option
copy()
Creates a new Socket object, not based on the source being copied.
int sendi2(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in big-endian format (network byte order) over the socket.
setSslVerifyMode(int mode)
sets the SSL verification mode
int shutdown()
Ensures that a socket will be closed even if the file descriptor is shared with other processes (for ...
constructor()
Creates the socket object.
nothing shutdownSSL()
Shuts down the SSL connection on a secure connection.
nothing setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
int recvu1(timeout timeout_ms=-1)
Receives a 1-byte unsigned integer from the socket.
nothing send2(binary bin, timeout timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
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...
string readHTTPHeaderString(timeout timeout_ms=-1)
Retuns a string representing the data in the HTTP header read (reads until "\r\n\r\n")
nothing sendHTTPMessage(string method, string path, string http_version, hash< auto > headers, *binary body, *reference< hash< auto >> info, timeout timeout_ms=-1)
Sends an HTTP message with a method and user-defined headers given as a hash and an optional message ...
hash< auto > readHTTPChunkedBody(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
int recvi4(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) signed integer in big-endian format (network byte order) from the socket.
string getEncoding()
Returns the character encoding for the socket.
nothing setEventQueue()
Removes any Queue object from the Socket object so that socket events are no longer added to the Queu...
nothing sendHTTPChunkedBodyTrailer(*hash< auto > trailer, timeout timeout_ms=-1)
Sends the trialer of an HTTP message body in chunked transfer encoding.
nothing upgradeClientToSSL(timeout timeout_ms=-1)
Upgrades a client socket connection to a TLS/SSL connection.
nothing setCharset(string encoding)
Sets the character encoding for the socket.
nothing connectUNIX(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to a UNIX domain socket file.
nothing sendHTTPResponseWithCallback(code scb, softint status_code, string status_desc, string http_version, hash< auto > headers, *reference< hash< auto >> info, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body to send with chun...
int sendBinary(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket's encoding,...
bool isDataAvailable(timeout timeout_ms=0)
Returns True or False depending on whether there is data to be read on the socket.
int setNoDelay(bool nd=True)
Sets the boolean TCP_NODELAY setting for the socket.
Socket acceptSSL()
Accepts connections on a listening socket and attempts to negotiate a TLS/SSL connection.
string recv(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a string tagged with the Socket's character encoding.
int recvu4(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) unsigned integer in big-endian format (network byte order) from the socket...
int recvi8(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in big-endian format (network byte order) from the socket.
hash< auto > readHTTPChunkedBodyToOutputStream(Qore::OutputStream os, timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding, writes it in an OutputStream and ret...
nothing sendHTTPMessage(string method, string path, string http_version, hash< auto > headers, string body, *reference< hash > info, timeout timeout_ms=-1)
Sends an HTTP message with a method and user-defined headers given as a hash and an optional message ...
int recvi2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in little-endian format from the socket.
int getPort()
Returns the port number of the socket for INET sockets.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, *binary body, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body as literal binary...
nothing bindUNIX(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Opens and binds the socket to the given UNIX domain socket file as given by the filename argument....
nothing setEncoding(string encoding)
Sets the character encoding for the socket.
nothing setPrivateKey(SSLPrivateKey key)
Sets the private key to use for negotiating encrypted connections along with the X....
nothing sendHTTPChunkedBodyFromInputStream(Qore::InputStream input_stream, int max_chunk_size=4096, timeout timeout_ms=-1, *code tcb)
Sends an HTTP message body in chunked transfer encoding.
string getCharset()
Returns the character encoding for the socket.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash< auto > headers, *binary body, *reference< hash< auto >> info, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and a message body as literal binary...
Queue objects provide a blocking, thread-safe message-passing object to Qore programs
Definition: QC_Queue.dox.h:22
const True
logical True
Definition: qc_qore.dox.h:98
const False
logical False
Definition: qc_qore.dox.h:96
const AF_LOCAL
POSIX synonym for AF_UNIX.
Definition: QC_Socket.dox.h:2993
const AF_INET6
IPv6 address family.
Definition: QC_Socket.dox.h:2991
const AF_UNIX
UNIX domain address family (UNIX socket files)
Definition: QC_Socket.dox.h:2995
const AFMap
mapping from Network Address Family Constants to string codes
Definition: QC_Socket.dox.h:2979
const AF_UNSPEC
unspecified address family
Definition: QC_Socket.dox.h:2997
const AF_INET
IPv4 address family.
Definition: QC_Socket.dox.h:2989
const AFStrMap
mapping from network address family string codes to Network Address Family Constants
Definition: QC_Socket.dox.h:2981
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:3012
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:3006
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:3010
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:3008
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:3017
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:3029
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:3025
const IPPROTO_TCP
for the TCP protocol
Definition: QC_Socket.dox.h:3037
const IPPROTO_UDP
for the UDP protocol
Definition: QC_Socket.dox.h:3039
const SOCK_POLLIN
(input and output) for polling for read events
Definition: QC_Socket.dox.h:2801
const SOCK_POLLERR
(output only) indicates that the socket or connection is closed
Definition: QC_Socket.dox.h:2799
const SOCK_POLLOUT
(input and output) for polling for write events
Definition: QC_Socket.dox.h:2803
const SOCK_STREAM
for sequenced, reliable, two-way connection-based byte streams (the default)
Definition: QC_Socket.dox.h:3051
const SOCK_RAW
raw socket interface, only available to the superuser, untested
Definition: QC_Socket.dox.h:3049
const SOCK_DGRAM
for datagrams (connectionless, unreliable messages of a fixed (typically small) maximum length
Definition: QC_Socket.dox.h:3047
const SSL_VERIFY_NONE
Do not verify the peer's certificate.
Definition: QC_Socket.dox.h:2843
const SSL_VERIFY_FAIL_IF_NO_PEER_CERT
Require a client certificate in server mode.
Definition: QC_Socket.dox.h:2834
const SSL_VERIFY_CLIENT_ONCE
Only request a client certificate once in server mode.
Definition: QC_Socket.dox.h:2822
const SSL_VERIFY_PEER
Verify the peer's certificate.
Definition: QC_Socket.dox.h:2860
list< auto > list(...)
Returns a list of the arguments passed at the top level.
binary binary()
Always returns an empty binary object (of zero length)
const X509_V_ERR_CERT_SIGNATURE_FAILURE
Certificate signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:2887
const X509_V_ERR_CERT_REJECTED
Root CA is marked to reject the specified purpose.
Definition: QC_Socket.dox.h:2883
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:2871
const X509_VerificationReasons
maps from varification strings to verification code descriptions
Definition: QC_Socket.dox.h:2937
const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
Format error in certificate's notBefore field (invalid time)
Definition: QC_Socket.dox.h:2901
const X509_V_ERR_PATH_LENGTH_EXCEEDED
The basicConstraints pathlength parameter has been exceeded.
Definition: QC_Socket.dox.h:2915
const X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The keyUsage extension does not permit certificate signing.
Definition: QC_Socket.dox.h:2911
const X509_V_ERR_INVALID_PURPOSE
The certificate cannot be used for the specified purpose.
Definition: QC_Socket.dox.h:2909
const X509_V_ERR_APPLICATION_VERIFICATION
Verification failure.
Definition: QC_Socket.dox.h:2875
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:2897
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:2923
const X509_V_ERR_UNABLE_TO_GET_CRL
Unable to get certificate CRL.
Definition: QC_Socket.dox.h:2927
const X509_V_OK
Verification OK.
Definition: QC_Socket.dox.h:2935
const X509_V_ERR_CRL_NOT_YET_VALID
CRL is not yet valid.
Definition: QC_Socket.dox.h:2893
const X509_V_ERR_CERT_CHAIN_TOO_LONG
Certificate chain too long.
Definition: QC_Socket.dox.h:2877
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:2931
const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
Unable to verify the first certificate.
Definition: QC_Socket.dox.h:2933
const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
Unable to decode issuer public key (SubjectPublicKeyInfo)
Definition: QC_Socket.dox.h:2921
const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
Format error in CRL's nextUpdate field (invalid time)
Definition: QC_Socket.dox.h:2905
const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
Format error in CRL's lastUpdate field (invalid time)
Definition: QC_Socket.dox.h:2903
const X509_V_ERR_CERT_REVOKED
Certificate has been revoked.
Definition: QC_Socket.dox.h:2885
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:2919
const X509_V_ERR_INVALID_CA
Invalid CA certificate.
Definition: QC_Socket.dox.h:2907
const X509_V_ERR_OUT_OF_MEM
Out of memory error.
Definition: QC_Socket.dox.h:2913
const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
Unable to get issuer certificate.
Definition: QC_Socket.dox.h:2929
const X509_V_ERR_CRL_HAS_EXPIRED
CRL has expired.
Definition: QC_Socket.dox.h:2891
const X509_V_ERR_CERT_UNTRUSTED
Root CA is not marked as trusted for the specified purpose.
Definition: QC_Socket.dox.h:2889
const X509_V_ERR_CERT_NOT_YET_VALID
Certificate is not yet valid.
Definition: QC_Socket.dox.h:2881
const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
Format error in certificate's notAfter field (invalid time)
Definition: QC_Socket.dox.h:2899
const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
Unable to decrypt CRL's signature.
Definition: QC_Socket.dox.h:2925
const X509_V_ERR_CERT_HAS_EXPIRED
Certificate has expired.
Definition: QC_Socket.dox.h:2879
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:2873
const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
Self signed certificate in certificate chain.
Definition: QC_Socket.dox.h:2917
const X509_V_ERR_CRL_SIGNATURE_FAILURE
CRL signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:2895
main Qore-language namespace
Definition: Pseudo_QC_All.dox.h:3
Socket poll info hash.
Definition: QC_Socket.dox.h:6
Socket socket
the socket to monitor
Definition: QC_Socket.dox.h:10
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