Qore Programming Language Reference Manual  0.8.9
 All Classes Namespaces Functions Variables Groups Pages
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 
178 Socket acceptSSL();
179 
180 public:
182 
198 *Socket acceptSSL(timeout timeout_ms);
199 
200 public:
202 
222 int bind(string str, softbool reuseaddr = False);
223 
224 public:
226 
240 int bind(int port, softbool reuseaddr = False);
241 
242 public:
244 
272 nothing bindINET(*string iface, *softstring service, softbool reuseaddr = False, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
273 
274 public:
276 
292 nothing bindUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
293 
294 public:
296 
305  clearStats();
306 
307 public:
309 
318 nothing clearWarningQueue();
319 
320 public:
322 
335 int close();
336 
337 public:
339 
364 nothing connect(string target, timeout timeout_ms = -1);
365 
366 public:
368 
392 nothing connectINET(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
393 
394 public:
396 
421 nothing connectINETSSL(string host, softstring service, timeout timeout_ms = -1, softint family = AF_UNSPEC, softint socktype = SOCK_STREAM, softint protocol = 0);
422 
423 public:
425 
453 nothing connectSSL(string target, timeout timeout_ms = -1);
454 
455 public:
457 
476 nothing connectUNIX(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
477 
478 public:
480 
500 nothing connectUNIXSSL(string path, softint socktype = SOCK_STREAM, softint protocol = 0);
501 
502 public:
504 
507  constructor();
508 
509 public:
511 
514  copy();
515 
516 public:
518 
524 string getCharset();
525 
526 public:
528 
533 string getEncoding();
534 
535 public:
537 
549 bool getNoDelay();
550 
551 public:
553 
568 hash getPeerInfo(bool host_lookup = True);
569 
570 public:
572 
582 int getPort();
583 
584 public:
586 
596 int getRecvTimeout();
597 
598 public:
600 
610 *string getSSLCipherName();
611 
612 public:
614 
624 *string getSSLCipherVersion();
625 
626 public:
628 
638 int getSendTimeout();
639 
640 public:
642 
652 int getSocket();
653 
654 public:
656 
671 hash getSocketInfo(bool host_lookup = True);
672 
673 public:
675 
697 
698 public:
700 
714 bool isDataAvailable(timeout timeout_ms = 0);
715 
716 public:
718 
728 bool isOpen();
729 
730 public:
732 
742 bool isSecure();
743 
744 public:
746 
760 bool isWriteFinished(timeout timeout_ms = 0);
761 
762 public:
764 
777 int listen(int backlog = 20);
778 
779 public:
781 
802 hash readHTTPChunkedBody(timeout timeout_ms = -1);
803 
804 public:
806 
827 hash readHTTPChunkedBodyBinary(timeout timeout_ms = -1);
828 
829 public:
831 
876 hash readHTTPHeader(timeout timeout_ms = -1, *reference info);
877 
878 public:
880 
903 string readHTTPHeaderString(timeout timeout_ms = -1);
904 
905 public:
907 
932 string recv(softint size = 0, timeout timeout_ms = -1);
933 
934 public:
936 
959 binary recvBinary(softint size = 0, timeout timeout_ms = -1);
960 
961 public:
963 
985 int recvi1(timeout timeout_ms = -1);
986 
987 public:
989 
1011 int recvi2(timeout timeout_ms = -1);
1012 
1013 public:
1015 
1037 int recvi2LSB(timeout timeout_ms = -1);
1038 
1039 public:
1041 
1063 int recvi4(timeout timeout_ms = -1);
1064 
1065 public:
1067 
1089 int recvi4LSB(timeout timeout_ms = -1);
1090 
1091 public:
1093 
1115 int recvi8(timeout timeout_ms = -1);
1116 
1117 public:
1119 
1141 int recvi8LSB(timeout timeout_ms = -1);
1142 
1143 public:
1145 
1167 int recvu1(timeout timeout_ms = -1);
1168 
1169 public:
1171 
1193 int recvu2(timeout timeout_ms = -1);
1194 
1195 public:
1197 
1219 int recvu2LSB(timeout timeout_ms = -1);
1220 
1221 public:
1223 
1245 int recvu4(timeout timeout_ms = -1);
1246 
1247 public:
1249 
1271 int recvu4LSB(timeout timeout_ms = -1);
1272 
1273 public:
1275 
1301 int send(binary bin, int timeout_ms = -1);
1302 
1303 public:
1305 
1333 int send(string str, timeout timeout_ms = -1);
1334 
1335 public:
1337 
1360 nothing send2(binary bin, timeout timeout_ms = -1);
1361 
1362 public:
1364 
1389 nothing send2(string str, timeout timeout_ms = -1);
1390 
1391 public:
1393 
1418 int sendBinary(string str, timeout timeout_ms = -1);
1419 
1420 public:
1422 
1447 int sendBinary(binary bin, timeout timeout_ms = -1);
1448 
1449 public:
1451 
1473 nothing sendBinary2(string str, timeout timeout_ms = -1);
1474 
1475 public:
1477 
1499 nothing sendBinary2(binary bin, timeout timeout_ms = -1);
1500 
1501 public:
1503 
1531 nothing sendHTTPMessage(string method, string path, string http_version, hash headers, *string body, *reference info, timeout timeout_ms = -1);
1532 
1533 public:
1535 
1561 nothing sendHTTPMessage(string method, string path, string http_version, hash headers, binary body, *reference info, timeout timeout_ms = -1);
1562 
1563 public:
1565 
1589 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash headers, *string body, timeout timeout_ms = -1);
1590 
1591 public:
1593 
1615 nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash headers, binary body, timeout timeout_ms = -1);
1616 
1617 public:
1619 
1642 int sendi1(softint i = 0, timeout timeout_ms = -1);
1643 
1644 public:
1646 
1669 int sendi2(softint i = 0, timeout timeout_ms = -1);
1670 
1671 public:
1673 
1696 int sendi2LSB(softint i = 0, timeout timeout_ms = -1);
1697 
1698 public:
1700 
1723 int sendi4(softint i = 0, timeout timeout_ms = -1);
1724 
1725 public:
1727 
1750 int sendi4LSB(softint i = 0, timeout timeout_ms = -1);
1751 
1752 public:
1754 
1777 int sendi8(softint i = 0, timeout timeout_ms = -1);
1778 
1779 public:
1781 
1804 int sendi8LSB(softint i = 0, timeout timeout_ms = -1);
1805 
1806 public:
1808 
1815 nothing setCertificate(SSLCertificate cert);
1816 
1817 public:
1819 
1826 nothing setCertificate(string cert_pem);
1827 
1828 public:
1830 
1837 nothing setCertificate(binary cert_der);
1838 
1839 public:
1841 
1844 nothing setCharset(string encoding);
1845 
1846 public:
1848 
1850 nothing setEncoding(string encoding);
1851 
1852 public:
1854 
1861 nothing setEventQueue();
1862 
1863 public:
1865 
1876 nothing setEventQueue(Queue queue);
1877 
1878 public:
1880 
1898 int setNoDelay(bool nd = True);
1899 
1900 public:
1902 
1909 nothing setPrivateKey(SSLPrivateKey key);
1910 
1911 public:
1913 
1921 nothing setPrivateKey(string key_pem, *string pass);
1922 
1923 public:
1925 
1932 nothing setPrivateKey(binary key_der);
1933 
1934 public:
1936 
1948 int setRecvTimeout(timeout timeout_ms);
1949 
1950 public:
1952 
1964 int setSendTimeout(timeout timeout_ms);
1965 
1966 public:
1968 
1998 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms = 1s);
1999 
2000 public:
2002 
2012 int shutdown();
2013 
2014 public:
2016 
2025 nothing shutdownSSL();
2026 
2027 public:
2029 
2034 nothing upgradeClientToSSL();
2035 
2036 public:
2038 
2043 nothing upgradeServerToSSL();
2044 
2045 public:
2047 
2057 *string verifyPeerCertificate();
2058 };
2066 
2068  const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH";
2070  const X509_V_ERR_AKID_SKID_MISMATCH = "X509_V_ERR_AKID_SKID_MISMATCH";
2072  const X509_V_ERR_APPLICATION_VERIFICATION = "X509_V_ERR_APPLICATION_VERIFICATION";
2074  const X509_V_ERR_CERT_CHAIN_TOO_LONG = "X509_V_ERR_CERT_CHAIN_TOO_LONG";
2076  const X509_V_ERR_CERT_HAS_EXPIRED = "X509_V_ERR_CERT_HAS_EXPIRED";
2078  const X509_V_ERR_CERT_NOT_YET_VALID = "X509_V_ERR_CERT_NOT_YET_VALID";
2080  const X509_V_ERR_CERT_REJECTED = "X509_V_ERR_CERT_REJECTED";
2082  const X509_V_ERR_CERT_REVOKED = "X509_V_ERR_CERT_REVOKED";
2084  const X509_V_ERR_CERT_SIGNATURE_FAILURE = "X509_V_ERR_CERT_SIGNATURE_FAILURE";
2086  const X509_V_ERR_CERT_UNTRUSTED = "X509_V_ERR_CERT_UNTRUSTED";
2088  const X509_V_ERR_CRL_HAS_EXPIRED = "X509_V_ERR_CRL_HAS_EXPIRED";
2090  const X509_V_ERR_CRL_NOT_YET_VALID = "X509_V_ERR_CRL_NOT_YET_VALID";
2092  const X509_V_ERR_CRL_SIGNATURE_FAILURE = "X509_V_ERR_CRL_SIGNATURE_FAILURE";
2094  const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT";
2096  const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
2098  const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
2100  const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD";
2102  const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD";
2104  const X509_V_ERR_INVALID_CA = "X509_V_ERR_INVALID_CA";
2106  const X509_V_ERR_INVALID_PURPOSE = "X509_V_ERR_INVALID_PURPOSE";
2108  const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = "X509_V_ERR_KEYUSAGE_NO_CERTSIGN";
2110  const X509_V_ERR_OUT_OF_MEM = "X509_V_ERR_OUT_OF_MEM";
2112  const X509_V_ERR_PATH_LENGTH_EXCEEDED = "X509_V_ERR_PATH_LENGTH_EXCEEDED";
2114  const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN";
2116  const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = "X509_V_ERR_SUBJECT_ISSUER_MISMATCH";
2118  const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY";
2120  const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE";
2122  const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE";
2124  const X509_V_ERR_UNABLE_TO_GET_CRL = "X509_V_ERR_UNABLE_TO_GET_CRL";
2126  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
2128  const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY";
2130  const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE";
2132  const X509_V_OK = "X509_V_OK";
2135  "X509_V_OK": "OK",
2136  "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT": "Unable to get issuer certificate",
2137  "X509_V_ERR_UNABLE_TO_GET_CRL": "Unable to get certificate CRL",
2138  "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",
2139  "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE": "Unable to decrypt CRL's signature",
2140  "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY": "Unable to decode issuer public key (SubjectPublicKeyInfo)",
2141  "X509_V_ERR_CERT_SIGNATURE_FAILURE": "Certificate signature failure; the signature of the certificate is invalid",
2142  "X509_V_ERR_CRL_SIGNATURE_FAILURE": "CRL signature failure; the signature of the certificate is invalid",
2143  "X509_V_ERR_CERT_NOT_YET_VALID": "Certificate is not yet valid",
2144  "X509_V_ERR_CERT_HAS_EXPIRED": "Certificate has expired",
2145  "X509_V_ERR_CRL_NOT_YET_VALID": "CRL is not yet valid",
2146  "X509_V_ERR_CRL_HAS_EXPIRED": "CRL has expired",
2147  "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD": "Format error in certificate's notBefore field (invalid time)",
2148  "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD": "Format error in certificate's notAfter field (invalid time)",
2149  "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD": "Format error in CRL's lastUpdate field (invalid time)",
2150  "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD": "Format error in CRL's nextUpdate field (invalid time)",
2151  "X509_V_ERR_OUT_OF_MEM": "Out of memory error",
2152  "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT": "Certificate is self-signed and cannot be found in the trusted list",
2153  "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN": "Self signed certificate in certificate chain",
2154  "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",
2155  "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE": "Unable to verify the first certificate",
2156  "X509_V_ERR_CERT_CHAIN_TOO_LONG": "Certificate chain too long",
2157  "X509_V_ERR_CERT_REVOKED": "Certificate has been revoked",
2158  "X509_V_ERR_INVALID_CA": "Invalid CA certificate",
2159  "X509_V_ERR_PATH_LENGTH_EXCEEDED": "The basicConstraints pathlength parameter has been exceeded",
2160  "X509_V_ERR_INVALID_PURPOSE": "The certificate cannot be used for the specified purpose",
2161  "X509_V_ERR_CERT_UNTRUSTED": "Root CA is not marked as trusted for the specified purpose",
2162  "X509_V_ERR_CERT_REJECTED": "Root CA is marked to reject the specified purpose",
2163  "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",
2164  "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",
2165  "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",
2166  "X509_V_ERR_KEYUSAGE_NO_CERTSIGN": "The keyUsage extension does not permit certificate signing",
2167  "X509_V_ERR_APPLICATION_VERIFICATION": "Verification failure",
2168  );
2170 
2174 
2176  const AF_INET = AF_INET;
2182  const AF_UNIX = AF_UNIX;
2186 
2191 
2195  const AI_ALL = AI_ALL;
2201 
2206 
2214 
2218 
2222 
2228 
2232 
2240 };
int shutdown()
Ensures that a socket will be closed even if the file descriptor is shared with other processes (for ...
int recvi1(timeout timeout_ms=-1)
Receives a 1-byte signed integer from the socket.
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:2094
const AF_UNSPEC
unspecified address family
Definition: QC_Socket.dox.h:2184
const SOCK_RAW
raw socket interface, only available to the superuser, untested
Definition: QC_Socket.dox.h:2236
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:2199
const X509_V_ERR_CERT_NOT_YET_VALID
Certificate is not yet valid.
Definition: QC_Socket.dox.h:2078
const X509_V_ERR_OUT_OF_MEM
Out of memory error.
Definition: QC_Socket.dox.h:2110
const X509_V_ERR_PATH_LENGTH_EXCEEDED
The basicConstraints pathlength parameter has been exceeded.
Definition: QC_Socket.dox.h:2112
nothing connectINETSSL(string host, softstring service, timeout timeout_ms=-1, softint family=AF_UNSPEC, softint socktype=SOCK_STREAM, softint protocol=0)
Connects to the given host and port and attempts to establish a TLS/SSL connection; accepts an option...
const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
Unable to decrypt certificate's signature. This means that the actual signature value could not be de...
Definition: QC_Socket.dox.h:2120
const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
Format error in CRL's lastUpdate field (invalid time)
Definition: QC_Socket.dox.h:2100
const X509_V_ERR_APPLICATION_VERIFICATION
Verification failure.
Definition: QC_Socket.dox.h:2072
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:p...
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:2195
int sendi4(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in big-endian format (network byte order) over the socket...
string readHTTPHeaderString(timeout timeout_ms=-1)
Retuns a string representing the data in the HTTP header read (reads until "\r\n\r\n") ...
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:2134
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:2086
hash getSocketInfo(bool host_lookup=True)
Returns information about the local socket as a hash.
int send(binary bin, int timeout_ms=-1)
Sends binary data over the socket; if any errors occur, an exception is thrown.
const X509_V_ERR_INVALID_CA
Invalid CA certificate.
Definition: QC_Socket.dox.h:2104
int recvi8LSB(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in little-endian format from the socket.
nothing bindUNIX(string path, softint socktype=SOCK_STREAM, softint protocol=0)
Opens and binds the socket to the given UNIX domain socket file as given by the filename argument...
nothing setPrivateKey(SSLPrivateKey key)
Sets the private key to use for negotiating encrypted connections along with the X.509 certificate.
nothing setCertificate(SSLCertificate cert)
Sets the X.509 certificate to use for negotiating encrypted connections.
string getCharset()
Returns the character encoding for the socket.
int recvi2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) signed integer in little-endian format from the socket.
const True
logical True
Definition: qc_qore.dox.h:94
nothing connect(string target, timeout timeout_ms=-1)
Connects to a remote port (if the string has a format "host:port") or UNIX domain socket file with an...
const AI_NUMERICSERV
If this bit is set, then the service is assumed to be a numeric port string, and no service lookup wi...
Definition: QC_Socket.dox.h:2204
hash getUsageInfo()
Returns performance statistics for the socket.
hash readHTTPChunkedBodyBinary(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
hash readHTTPHeader(timeout timeout_ms=-1, *reference info)
Retuns a hash representing the data in the HTTP header read, or, if the data cannot be parsed as an H...
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 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
Unable to get issuer certificate.
Definition: QC_Socket.dox.h:2126
*string getSSLCipherVersion()
Returns the version string of the cipher for an encrypted connection or NOTHING if a secure connectio...
hash readHTTPChunkedBody(timeout timeout_ms=-1)
Reads in an HTTP message body sent in chunked transfer encoding and returns it with any footers recei...
int setSendTimeout(timeout timeout_ms)
sets the send timeout as a socket option
int recvu4(timeout timeout_ms=-1)
Receives a 4-byte (32-bit) unsigned integer in big-endian format (network byte order) from the socket...
int recvu2LSB(timeout timeout_ms=-1)
Receives a 2-byte (16-bit) unsigned integer in little-endian format from the socket.
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.
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
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.
nothing sendHTTPResponse(softint status_code, string status_desc, string http_version, hash headers, *string body, timeout timeout_ms=-1)
Sends an HTTP response with user-defined headers given as a hash and an optional message body...
const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
Unable to verify the first certificate.
Definition: QC_Socket.dox.h:2130
const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
Unable to decode issuer public key (SubjectPublicKeyInfo)
Definition: QC_Socket.dox.h:2118
int sendi2LSB(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in little-endian format over the socket.
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:2090
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:2070
const X509_V_ERR_INVALID_PURPOSE
The certificate cannot be used for the specified purpose.
Definition: QC_Socket.dox.h:2106
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:2102
*string verifyPeerCertificate()
Returns a string code giving the result of verifying the remote certificate or NOTHING if an encrypte...
bool getNoDelay()
Returns the TCP_NODELAY setting for the socket.
int recvi8(timeout timeout_ms=-1)
Receives an 8-byte (64-bit) signed integer in big-endian format (network byte order) from the socket...
nothing connectSSL(string target, timeout timeout_ms=-1)
Connects to a remote socket and attempts to establish a TLS/SSL connection; accepts an optional timeo...
const X509_V_ERR_UNABLE_TO_GET_CRL
Unable to get certificate CRL.
Definition: QC_Socket.dox.h:2124
const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
Format error in certificate's notAfter field (invalid time)
Definition: QC_Socket.dox.h:2096
const X509_V_ERR_KEYUSAGE_NO_CERTSIGN
The keyUsage extension does not permit certificate signing.
Definition: QC_Socket.dox.h:2108
nothing sendHTTPMessage(string method, string path, string http_version, hash headers, *string body, *reference 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_ERR_CERT_REJECTED
Root CA is marked to reject the specified purpose.
Definition: QC_Socket.dox.h:2080
binary recvBinary(softint size=0, timeout timeout_ms=-1)
Receives data from the socket and returns a binary object.
int sendi1(softint i=0, timeout timeout_ms=-1)
Sends a 1-byte integer over the socket.
This class implements a container for private key data.
Definition: QC_SSLPrivateKey.dox.h:5
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:2178
const AF_INET
IPv4 address family.
Definition: QC_Socket.dox.h:2176
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
const IPPROTO_UDP
for the UDP protocol
Definition: QC_Socket.dox.h:2226
const X509_V_ERR_CERT_SIGNATURE_FAILURE
Certificate signature failure; the signature of the certificate is invalid.
Definition: QC_Socket.dox.h:2084
constructor()
Creates the socket object.
int sendi4LSB(softint i=0, timeout timeout_ms=-1)
Sends a 4-byte (32-bit) integer in little-endian format over the socket.
const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
Unable to get local issuer certificate. This normally means the list of trusted certificates is not c...
Definition: QC_Socket.dox.h:2128
const X509_V_ERR_CERT_REVOKED
Certificate has been revoked.
Definition: QC_Socket.dox.h:2082
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:2068
const AF_UNIX
UNIX domain address family (UNIX socket files)
Definition: QC_Socket.dox.h:2182
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:2224
const X509_V_OK
Verification OK.
Definition: QC_Socket.dox.h:2132
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:2180
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:2216
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:2116
nothing sendBinary2(string str, timeout timeout_ms=-1)
Sends string data over the socket without converting the string to the socket's encoding, but instead is sent exactly as-is; if any errors occur, an exception is thrown.
int sendi8(softint i=0, timeout timeout_ms=-1)
Sends an 8-byte (64-bit) integer in big-endian format (network byte order) over the socket...
SSLCertificate objects allow Qore code to work with X.509 certificate data.
Definition: QC_SSLCertificate.dox.h:5
hash getPeerInfo(bool host_lookup=True)
Returns a hash of information about the remote end for connected sockets.
int sendi2(softint i=0, timeout timeout_ms=-1)
Sends a 2-byte (16-bit) integer in big-endian format (network byte order) over the socket...
const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
Format error in certificate's notBefore field (invalid time)
Definition: QC_Socket.dox.h:2098
*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:2092
bool isSecure()
Returns True if the connection is a secure TLS/SSL connection.
bool isOpen()
Returns True if the socket is open.
nothing upgradeServerToSSL()
Upgrades a server socket connection to a TLS/SSL connection.
nothing upgradeClientToSSL()
Upgrades a client socket connection to a TLS/SSL connection.
const X509_V_ERR_CERT_HAS_EXPIRED
Certificate has expired.
Definition: QC_Socket.dox.h:2076
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:2197
clearStats()
Clears performance statistics.
nothing shutdownSSL()
Shuts down the SSL connection on a secure connection.
bool isDataAvailable(timeout timeout_ms=0)
Returns True or False depending on whether there is data to be read on the socket.
hash hash(object obj)
Returns a hash of an object's members.
const SOCK_STREAM
for sequenced, reliable, two-way connection-based byte streams (the default)
Definition: QC_Socket.dox.h:2238
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:2193
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, 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:2074
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:2114
const X509_V_ERR_CRL_HAS_EXPIRED
CRL has expired.
Definition: QC_Socket.dox.h:2088
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:2212
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:2234
const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
Unable to decrypt CRL's signature.
Definition: QC_Socket.dox.h:2122