Qore Programming Language 1.14.2
|
provides access to sockets using Qore data structures More...
#include <QoreSocket.h>
Public Member Methods | |
DLLEXPORT | QoreSocket () |
creates an empty, unconnected socket | |
DLLEXPORT | ~QoreSocket () |
disconnects if necessary, frees all data, and destroys the socket | |
DLLEXPORT QoreSocket * | accept (int timeout_ms, ExceptionSink *xsink) |
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned More... | |
DLLEXPORT QoreSocket * | accept (SocketSource *source, ExceptionSink *xsink) |
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection More... | |
DLLEXPORT void | acceptAllCertificates (bool accept_all=true) |
with peer verification enabled, all certificates are accepted regardless of the validity of the Certificate Authority More... | |
DLLEXPORT int | acceptAndReplace (int timeout_ms, ExceptionSink *xsink) |
accepts a new connection on a listening socket and replaces the current socket with the new connection with a timeout; if no connection is accepted within the timeout period, -3 (QSE_TIMEOUT) is returned More... | |
DLLEXPORT int | acceptAndReplace (SocketSource *source) |
accepts a new connection on a listening socket and replaces the current socket with the new connection More... | |
DLLEXPORT QoreSocket * | acceptSSL (int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned More... | |
DLLEXPORT QoreSocket * | acceptSSL (SocketSource *source, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreSocket object for the new connection More... | |
DLLEXPORT int | asyncIoWait (int timeout_ms, bool read, bool write) const |
returns 1 if the event was satisfied in the timeout period, 0 if not (= timeout), or -1 in case of an error (see errno in this case) More... | |
DLLEXPORT int | bind (const char *iface, int prt, bool reuseaddr=false) |
binds to a TCP INET (ipv4 only) port on the given interface and returns a status code More... | |
DLLEXPORT int | bind (const char *name, bool reuseaddr=false) |
binds to a UNIX domain socket or INET interface:port using TCP and returns a status code More... | |
DLLEXPORT int | bind (const hashdecl sockaddr *addr, int addr_size) |
binds an INET TCP socket to a specific socket address - do not use, deprecated, use bind(int family, const hashdecl sockaddr *addr, int addr_size, int socktype, int protocol) instead More... | |
DLLEXPORT int | bind (int family, const hashdecl sockaddr *addr, int addr_size, int socktype=Q_SOCK_STREAM, int protocol=0) |
binds an INET or INET6 TCP socket to a specific socket address More... | |
DLLEXPORT int | bind (int prt, bool reuseaddr) |
binds to a TCP INET (ipv4 only) port on all interfaces and returns a status code More... | |
DLLEXPORT int | bindINET (const char *name, const char *service, bool reuseaddr=true, int family=Q_AF_UNSPEC, int socktype=Q_SOCK_STREAM, int protocol=0, ExceptionSink *xsink=nullptr) |
binds an INET or INET6 TCP socket to a specific socket address More... | |
DLLEXPORT int | bindUNIX (const char *name, ExceptionSink *xsink=nullptr) |
binds to a UNIX domain socket and returns a status code More... | |
DLLEXPORT int | bindUNIX (const char *name, int socktype, int protocol=0, ExceptionSink *xsink=nullptr) |
binds to a UNIX domain socket and returns a status code More... | |
DLLEXPORT bool | captureRemoteCertificates (bool set) |
sets the capture SSL certificate flag More... | |
DLLEXPORT void | cleanup (ExceptionSink *xsink) |
posts deleted message and removes any event queue | |
DLLEXPORT int | close () |
closes the socket More... | |
DLLEXPORT int | connect (const char *name, ExceptionSink *xsink=nullptr) |
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connect (const char *name, int timeout_ms, ExceptionSink *xsink=nullptr) |
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectINET (const char *host, int prt, ExceptionSink *xsink=nullptr) |
connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectINET (const char *host, int prt, int timeout_ms, ExceptionSink *xsink=nullptr) |
connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectINET2 (const char *name, const char *service, int family=Q_AF_UNSPEC, int sock_type=Q_SOCK_STREAM, int protocol=0, int timeout_ms=-1, ExceptionSink *xsink=nullptr) |
connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectINET2SSL (const char *name, const char *service, int family, int sock_type, int protocol, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink=nullptr) |
connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectINETSSL (const char *host, int prt, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
connects to an INET socket by hostname and port number, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectINETSSL (const char *host, int prt, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
connects to an INET socket by hostname and port number, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectSSL (const char *name, int timeout_ms, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectSSL (const char *name, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectUNIX (const char *p, ExceptionSink *xsink=nullptr) |
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectUNIX (const char *p, int socktype, int protocol=0, ExceptionSink *xsink=nullptr) |
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectUNIXSSL (const char *p, int socktype, int protocol, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT int | connectUNIXSSL (const char *p, X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors More... | |
DLLEXPORT bool | getAcceptAllCertificates () const |
returns the current value of the "accept all certificates" flag More... | |
DLLEXPORT int64 | getConnectionId () const |
returns a connection ID to help identifying when new connections are made More... | |
DLLEXPORT const QoreEncoding * | getEncoding () const |
returns the character encoding associated with this socket More... | |
DLLLOCAL int64 | getObjectIDForEvents () const |
returns a unique ID for the socket to be used in event messages | |
DLLEXPORT QoreHashNode * | getPeerInfo (ExceptionSink *xsink) const |
returns peer information for a connected socket More... | |
DLLEXPORT QoreHashNode * | getPeerInfo (ExceptionSink *xsink, bool host_lookup) const |
returns peer information for a connected socket More... | |
DLLEXPORT int | getPort () |
returns the TCP port number, also assigns the interal port number if it must be discovered | |
DLLLOCAL Queue * | getQueue () |
returns the event queue (not part of the library's public API) | |
DLLEXPORT int | getRecvTimeout () const |
get recv timeout in milliseconds | |
DLLEXPORT QoreObject * | getRemoteCertificate () const |
returns a remote certificate if available More... | |
DLLEXPORT int | getSendTimeout () const |
get send timeout in milliseconds | |
DLLEXPORT int | getSocket () const |
returns the file descriptor associated with this socket More... | |
DLLEXPORT QoreHashNode * | getSocketInfo (ExceptionSink *xsink) const |
returns information for the current socket; the socket must be open More... | |
DLLEXPORT QoreHashNode * | getSocketInfo (ExceptionSink *xsink, bool host_lookup) const |
returns information for the current socket; the socket must be open More... | |
DLLEXPORT const char * | getSSLCipherName () const |
returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none More... | |
DLLEXPORT const char * | getSSLCipherVersion () const |
returns the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none More... | |
DLLEXPORT int | getSslVerifyMode () const |
returns the SSL verification mode More... | |
DLLEXPORT bool | isDataAvailable (ExceptionSink *xsink, int timeout_ms=0) const |
returns true if data is available on the socket in the timeout period in milliseconds More... | |
DLLEXPORT bool | isDataAvailable (int timeout_ms=0) const |
returns true if data is available on the socket in the timeout period in milliseconds More... | |
DLLEXPORT bool | isOpen () const |
returns true if the socket is open More... | |
DLLEXPORT bool | isSecure () const |
returns true if an SSL connection is active More... | |
DLLEXPORT bool | isWriteFinished (ExceptionSink *xsink, int timeout_ms=0) const |
returns true if all write data has been written within the timeout period in milliseconds More... | |
DLLEXPORT bool | isWriteFinished (int timeout_ms=0) const |
returns true if all write data has been written within the timeout period in milliseconds More... | |
DLLEXPORT int | listen () |
sets an open socket to the listening state More... | |
DLLEXPORT int | listen (int backlog) |
sets an open socket to the listening state More... | |
DLLEXPORT bool | pendingHttpChunkedBody () const |
returns true if a HTTP header was read indicating chunked transfer encoding, but no chunked body has been read | |
DLLEXPORT QoreHashNode * | readHTTPChunkedBody (int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET) |
receive a string message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count returned More... | |
DLLEXPORT QoreHashNode * | readHTTPChunkedBodyBinary (int timeout_ms, ExceptionSink *xsink, int source=QORE_SOURCE_SOCKET) |
receive a binary message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count returned More... | |
DLLEXPORT QoreHashNode * | readHTTPHeader (ExceptionSink *xsink, QoreHashNode *info, int timeout_ms, int source=QORE_SOURCE_SOCKET) |
read and parse HTTP header, caller owns QoreHashNode reference count returned More... | |
DLLEXPORT AbstractQoreNode * | readHTTPHeader (int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET) |
read and parse HTTP header, caller owns AbstractQoreNode reference count returned More... | |
DLLEXPORT AbstractQoreNode * | readHTTPHeader (QoreHashNode *info, int timeout_ms, int *prc, int source=QORE_SOURCE_SOCKET) |
read and parse HTTP header, caller owns AbstractQoreNode reference count returned More... | |
DLLEXPORT QoreStringNode * | readHTTPHeaderString (ExceptionSink *xsink, int timeout_ms, int source=QORE_SOURCE_SOCKET) |
read a HTTP header, caller owns QoreStringNode reference count returned More... | |
DLLEXPORT int | recv (int fd, qore_offset_t size, int timeout_ms) |
receive data on the socket and write it to a file descriptor More... | |
DLLEXPORT int | recv (int fd, qore_offset_t size, int timeout_ms, ExceptionSink *xsink) |
receive data on the socket and write it to a file descriptor More... | |
DLLEXPORT QoreStringNode * | recv (int timeout_ms, ExceptionSink *xsink) |
receive with a timeout value and return a QoreStringNode, caller owns the reference count returned More... | |
DLLEXPORT QoreStringNode * | recv (int timeout_ms, int *prc) |
receive with a timeout value and return a QoreStringNode, caller owns the reference count returned More... | |
DLLEXPORT QoreStringNode * | recv (qore_offset_t bufsize, int timeout_ms, ExceptionSink *xsink) |
receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned More... | |
DLLEXPORT QoreStringNode * | recv (qore_offset_t bufsize, int timeout_ms, int *prc) |
receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned More... | |
DLLEXPORT BinaryNode * | recvBinary (int timeout_ms, ExceptionSink *xsink) |
receive with a timeout value and return a BinaryNode, caller owns the reference count returned More... | |
DLLEXPORT BinaryNode * | recvBinary (int timeout_ms, int *prc) |
receive with a timeout value and return a BinaryNode, caller owns the reference count returned More... | |
DLLEXPORT BinaryNode * | recvBinary (qore_offset_t bufsize, int timeout_ms, ExceptionSink *xsink) |
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the reference count returned More... | |
DLLEXPORT BinaryNode * | recvBinary (qore_offset_t bufsize, int timeout_ms, int *prc) |
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the reference count returned More... | |
DLLEXPORT int | recvi1 (int timeout_ms, char *val) |
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi1 (int timeout_ms, char *val, ExceptionSink *xsink) |
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvi2 (int timeout_ms, short *val) |
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi2 (int timeout_ms, short *val, ExceptionSink *xsink) |
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvi2LSB (int timeout_ms, short *val) |
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi2LSB (int timeout_ms, short *val, ExceptionSink *xsink) |
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvi4 (int timeout_ms, int *val) |
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi4 (int timeout_ms, int *val, ExceptionSink *xsink) |
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvi4LSB (int timeout_ms, int *val) |
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi4LSB (int timeout_ms, int *val, ExceptionSink *xsink) |
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvi8 (int timeout_ms, int64 *val) |
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi8 (int timeout_ms, int64 *val, ExceptionSink *xsink) |
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvi8LSB (int timeout_ms, int64 *val) |
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvi8LSB (int timeout_ms, int64 *val, ExceptionSink *xsink) |
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvu1 (int timeout_ms, unsigned char *val) |
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvu1 (int timeout_ms, unsigned char *val, ExceptionSink *xsink) |
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvu2 (int timeout_ms, unsigned short *val) |
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvu2 (int timeout_ms, unsigned short *val, ExceptionSink *xsink) |
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvu2LSB (int timeout_ms, unsigned short *val) |
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvu2LSB (int timeout_ms, unsigned short *val, ExceptionSink *xsink) |
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvu4 (int timeout_ms, unsigned int *val) |
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvu4 (int timeout_ms, unsigned int *val, ExceptionSink *xsink) |
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | recvu4LSB (int timeout_ms, unsigned int *val) |
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int64 | recvu4LSB (int timeout_ms, unsigned int *val, ExceptionSink *xsink) |
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter More... | |
DLLEXPORT int | send (const BinaryNode *msg) |
sends binary data on a connected socket More... | |
DLLEXPORT int | send (const BinaryNode *msg, ExceptionSink *xsink) |
sends binary data on a connected socket More... | |
DLLEXPORT int | send (const BinaryNode *msg, int timeout_ms, ExceptionSink *xsink) |
sends binary data on a connected socket More... | |
DLLEXPORT int | send (const char *buf, size_t size) |
sends binary data on a connected socket More... | |
DLLEXPORT int | send (const char *buf, size_t size, ExceptionSink *xsink) |
sends binary data on a connected socket More... | |
DLLEXPORT int | send (const char *buf, size_t size, int timeout_ms, ExceptionSink *xsink) |
sends binary data on a connected socket More... | |
DLLEXPORT int | send (const QoreString *msg, ExceptionSink *xsink) |
sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary More... | |
DLLEXPORT int | send (const QoreString *msg, int timeout_ms, ExceptionSink *xsink) |
sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary More... | |
DLLEXPORT int | send (const QoreStringNode &msg, int timeout_ms, ExceptionSink *xsink) |
sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary More... | |
DLLEXPORT int | send (int fd, qore_offset_t size, int timeout_ms, ExceptionSink *xsink) |
sends untranslated data from an open file descriptor More... | |
DLLEXPORT int | send (int fd, qore_offset_t size=-1) |
sends untranslated data from an open file descriptor More... | |
DLLEXPORT int | sendHTTPMessage (const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET) |
send an HTTP request message on the socket More... | |
DLLEXPORT int | sendHTTPMessage (ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms) |
send an HTTP request message on the socket with a timeout value More... | |
DLLEXPORT int | sendHTTPMessage (ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET) |
send an HTTP request message on the socket More... | |
DLLEXPORT int | sendHTTPMessage (QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET) |
send an HTTP request message on the socket More... | |
DLLEXPORT int | sendHTTPMessageWithCallback (ExceptionSink *xsink, QoreHashNode *info, const char *method, const char *path, const char *http_version, const QoreHashNode *headers, const ResolvedCallReferenceNode &send_callback, int source, int timeout_ms) |
send an HTTP request message on the socket with a timeout value with a chunked message body using a calback More... | |
DLLEXPORT int | sendHTTPResponse (ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms) |
send an HTTP response message on the socket More... | |
DLLEXPORT int | sendHTTPResponse (ExceptionSink *xsink, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET) |
send an HTTP response message on the socket More... | |
DLLEXPORT int | sendHTTPResponse (ExceptionSink *xsink, QoreHashNode *info, int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source, int timeout_ms) |
send an HTTP response message on the socket More... | |
DLLEXPORT int | sendHTTPResponse (int code, const char *desc, const char *http_version, const QoreHashNode *headers, const void *data, size_t size, int source=QORE_SOURCE_SOCKET) |
send an HTTP response message on the socket More... | |
DLLEXPORT int | sendi1 (char i) |
sends a 1-byte binary integer data to a connected socket More... | |
DLLEXPORT int | sendi1 (char i, int timeout_ms, ExceptionSink *xsink) |
sends a 1-byte binary integer data to a connected socket More... | |
DLLEXPORT int | sendi2 (short i) |
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More... | |
DLLEXPORT int | sendi2 (short i, int timeout_ms, ExceptionSink *xsink) |
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More... | |
DLLEXPORT int | sendi2LSB (short i) |
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More... | |
DLLEXPORT int | sendi2LSB (short i, int timeout_ms, ExceptionSink *xsink) |
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More... | |
DLLEXPORT int | sendi4 (int i) |
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More... | |
DLLEXPORT int | sendi4 (int i, int timeout_ms, ExceptionSink *xsink) |
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More... | |
DLLEXPORT int | sendi4LSB (int i) |
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More... | |
DLLEXPORT int | sendi4LSB (int i, int timeout_ms, ExceptionSink *xsink) |
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More... | |
DLLEXPORT int | sendi8 (int64 i) |
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More... | |
DLLEXPORT int | sendi8 (int64 i, int timeout_ms, ExceptionSink *xsink) |
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket More... | |
DLLEXPORT int | sendi8LSB (int64 i) |
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More... | |
DLLEXPORT int | sendi8LSB (int64 i, int timeout_ms, ExceptionSink *xsink) |
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket More... | |
DLLLOCAL void | setAccept (QoreObject *o) |
sets backwards-compatible members on accept in a new object - will be removed in a future version of qore | |
DLLEXPORT void | setEncoding (const QoreEncoding *id) |
sets the character encoding for strings sent and received with this socket More... | |
DLLLOCAL void | setEventQueue (ExceptionSink *xsink, Queue *q, QoreValue arg, bool with_data) |
sets the event queue (not part of the library's pubilc API), must be already referenced before call | |
DLLEXPORT int | setRecvTimeout (int ms) |
set recv timeout in milliseconds | |
DLLEXPORT int | setSendTimeout (int ms) |
set send timeout in milliseconds | |
DLLEXPORT void | setSslVerifyMode (int mode) |
sets the SSL verification mode More... | |
DLLEXPORT int | shutdown () |
calls shutdown on the socket More... | |
DLLEXPORT int | shutdownSSL (ExceptionSink *xsink) |
shuts down an active SSL connection More... | |
DLLEXPORT AbstractPollState * | startConnect (ExceptionSink *xsink, const char *name) |
Starts a non-blocking connection to a socket and returns a status code. More... | |
DLLEXPORT AbstractPollState * | startRecv (ExceptionSink *xsink, size_t size) |
Starts a non-blocking receive operation on a connected socket. More... | |
DLLEXPORT AbstractPollState * | startRecvUntilBytes (ExceptionSink *xsink, const char *pattern, size_t size) |
Starts a non-blocking receive operation on a connected socket. More... | |
DLLEXPORT AbstractPollState * | startSend (ExceptionSink *xsink, const char *data, size_t size) |
Starts a non-blocking send operation on a connected socket. More... | |
DLLEXPORT AbstractPollState * | startSslConnect (ExceptionSink *xsink, X509 *cert=nullptr, EVP_PKEY *pkey=nullptr) |
Starts a non-blocking upgrade to an SSL connection on a connected client connection. More... | |
DLLEXPORT int | upgradeClientToSSL (X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
negotiates an SSL connection from the client side More... | |
DLLEXPORT int | upgradeClientToSSL (X509 *cert, EVP_PKEY *pkey, int timeout_ms, ExceptionSink *xsink) |
negotiates an SSL connection from the client side More... | |
DLLEXPORT int | upgradeServerToSSL (X509 *cert, EVP_PKEY *pkey, ExceptionSink *xsink) |
negotiates an SSL connection from the client side More... | |
DLLEXPORT int | upgradeServerToSSL (X509 *cert, EVP_PKEY *pkey, int timeout_ms, ExceptionSink *xsink) |
negotiates an SSL connection from the client side More... | |
DLLEXPORT long | verifyPeerCertificate () const |
returns the peer certificate verification code if an SSL connection is in progress | |
Friends | |
class | QoreFtpClient |
provides access to sockets using Qore data structures
QoreSocket objects also have a QoreEncoding associated with them used for sending and receiving string data. String data received from the socket will be tagged with the appropriate encoding; string data send through the socket will be implicitly converted to the socket's encoding if necessary. This class does no implement any thread locking; thread locking must be performed at a higher level (for example, as with QoreHTTPClient and QoreFtpClient).
DLLEXPORT QoreSocket * QoreSocket::accept | ( | int | timeout_ms, |
ExceptionSink * | xsink | ||
) |
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned
the socket must be opened and in a listening state before making this call.
timeout_ms | the timeout in milliseconds; if a timeout occurs then 0 is returned (no Qore-language excepton is raised) |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT QoreSocket * QoreSocket::accept | ( | SocketSource * | source, |
ExceptionSink * | xsink | ||
) |
accepts a new connection on a listening socket and returns a new QoreSocket object for the new connection
the socket must be opened and in a listening state before making this call.
source | source connection information will be written to this object if not 0 |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT void QoreSocket::acceptAllCertificates | ( | bool | accept_all = true | ) |
with peer verification enabled, all certificates are accepted regardless of the validity of the Certificate Authority
accept_all | if true, accepts self-signed certs, if false, then not |
DLLEXPORT int QoreSocket::acceptAndReplace | ( | int | timeout_ms, |
ExceptionSink * | xsink | ||
) |
accepts a new connection on a listening socket and replaces the current socket with the new connection with a timeout; if no connection is accepted within the timeout period, -3 (QSE_TIMEOUT) is returned
the socket must be opened and in a listening state before making this call.
timeout_ms | the timeout in milliseconds; if a timeout occurs then 0 is returned (no Qore-language excepton is raised) |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::acceptAndReplace | ( | SocketSource * | source | ) |
accepts a new connection on a listening socket and replaces the current socket with the new connection
the socket must be opened and in a listening state before making this call.
source | source connection information will be written to this object if not 0 |
DLLEXPORT QoreSocket * QoreSocket::acceptSSL | ( | int | timeout_ms, |
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreSocket object for the new connection with a timeout; if no connection is accepted within the timeout period 0 is returned
the socket must be opened and in a listening state before making this call.
timeout_ms | the timeout in milliseconds; if a timeout occurs then 0 is returned (no Qore-language excepton is raised) |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT QoreSocket * QoreSocket::acceptSSL | ( | SocketSource * | source, |
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
accepts a new connection on a listening socket, negotiates an SSL connection, and returns a new QoreSocket object for the new connection
the socket must be opened and in a listening state before making this call.
source | source connection information will be written to this object if not 0 |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::asyncIoWait | ( | int | timeout_ms, |
bool | read, | ||
bool | write | ||
) | const |
returns 1 if the event was satisfied in the timeout period, 0 if not (= timeout), or -1 in case of an error (see errno in this case)
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
read | wait for data to be available for reading from the socket |
write | wait for data to be written on the socket |
DLLEXPORT int QoreSocket::bind | ( | const char * | iface, |
int | prt, | ||
bool | reuseaddr = false |
||
) |
binds to a TCP INET (ipv4 only) port on the given interface and returns a status code
iface | the interface to bind to (hostname or IP address) |
prt | the port to bind to |
reuseaddr | if true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example |
DLLEXPORT int QoreSocket::bind | ( | const char * | name, |
bool | reuseaddr = false |
||
) |
binds to a UNIX domain socket or INET interface:port using TCP and returns a status code
name | address:port or filename to bind to; if the name has a ':' in it; it's assumed to be an address:port specification for binding to an INET socket, otherwise it is assumed to be a file name for a UNIX domain socket. If there is more than 1 ':' in the name, then the address is assumed to be an ipv6 interface address, otherwise it is assumed to be an ipv4 address. |
reuseaddr | if true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example |
DLLEXPORT int QoreSocket::bind | ( | const hashdecl sockaddr * | addr, |
int | addr_size | ||
) |
binds an INET TCP socket to a specific socket address - do not use, deprecated, use bind(int family, const hashdecl sockaddr *addr, int addr_size, int socktype, int protocol) instead
this function will not set the port number; use bind(int family, const hashdecl sockaddr *addr, int addr_size) instead
addr | the socket address to bind to |
addr_size | the size of the addr argument |
DLLEXPORT int QoreSocket::bind | ( | int | family, |
const hashdecl sockaddr * | addr, | ||
int | addr_size, | ||
int | socktype = Q_SOCK_STREAM , |
||
int | protocol = 0 |
||
) |
binds an INET or INET6 TCP socket to a specific socket address
family | the address family (AF_INET or AF_INET6) |
addr | the socket address to bind to |
addr_size | the size of the addr argument |
socktype | the type of socket (SOCK_STREAM = tcp socket) |
protocol | the protocol for the socket |
DLLEXPORT int QoreSocket::bind | ( | int | prt, |
bool | reuseaddr | ||
) |
binds to a TCP INET (ipv4 only) port on all interfaces and returns a status code
prt | the port to bind to |
reuseaddr | if true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example |
DLLEXPORT int QoreSocket::bindINET | ( | const char * | name, |
const char * | service, | ||
bool | reuseaddr = true , |
||
int | family = Q_AF_UNSPEC , |
||
int | socktype = Q_SOCK_STREAM , |
||
int | protocol = 0 , |
||
ExceptionSink * | xsink = nullptr |
||
) |
binds an INET or INET6 TCP socket to a specific socket address
name | the name or address of the interface, can be 0 meaning all interfaces |
service | the service name or port number |
reuseaddr | if true then setsockopt() will be called with SO_REUSEADDR, allowing the bind to succeed even if the port is still in a TIME_WAIT state, for example |
family | the address family (AF_INET, AF_INET6, or AF_UNSPEC) |
socktype | the type of socket (SOCK_STREAM = tcp socket) |
protocol | the protocol for the socket |
xsink | if not 0 and an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::bindUNIX | ( | const char * | name, |
ExceptionSink * | xsink = nullptr |
||
) |
binds to a UNIX domain socket and returns a status code
name | UNIX filename to bind to |
xsink | if not 0 and an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::bindUNIX | ( | const char * | name, |
int | socktype, | ||
int | protocol = 0 , |
||
ExceptionSink * | xsink = nullptr |
||
) |
binds to a UNIX domain socket and returns a status code
name | UNIX filename to bind to |
socktype | the type of socket (SOCK_STREAM = tcp socket) |
protocol | the protocol for the socket (use 0 for default) |
xsink | if not 0 and an error occurs, the Qore-language exception information will be added here |
DLLEXPORT bool QoreSocket::captureRemoteCertificates | ( | bool | set | ) |
sets the capture SSL certificate flag
set | the new value of the flag |
DLLEXPORT int QoreSocket::close | ( | ) |
closes the socket
Deletes the socket file if it was a UNIX domain socket and was created with the QoreSocket::bind() call. Also implicitly calls QoreSocket::shutdownSSL() if an SSL connection is active.
DLLEXPORT int QoreSocket::connect | ( | const char * | name, |
ExceptionSink * | xsink = nullptr |
||
) |
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors
If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINET() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIX() is called.
name | the name of the socket (either hostname:port or file name) |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connect | ( | const char * | name, |
int | timeout_ms, | ||
ExceptionSink * | xsink = nullptr |
||
) |
connects to a socket and returns a status code, Qore-language exceptions are raised in the case of any errors
If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINET() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIX() is called.
name | the name of the socket (either hostname:port or file name) |
timeout_ms | the timeout period in milliseconds |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectINET | ( | const char * | host, |
int | prt, | ||
ExceptionSink * | xsink = nullptr |
||
) |
connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors
host | the name or IP address of the host |
prt | the port number of the remote socket |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectINET | ( | const char * | host, |
int | prt, | ||
int | timeout_ms, | ||
ExceptionSink * | xsink = nullptr |
||
) |
connects to an INET socket by hostname and port number and returns a status code, Qore-language exceptions are raised in the case of any errors
host | the name or IP address of the host |
prt | the port number of the remote socket |
timeout_ms | the timeout period in milliseconds |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectINET2 | ( | const char * | name, |
const char * | service, | ||
int | family = Q_AF_UNSPEC , |
||
int | sock_type = Q_SOCK_STREAM , |
||
int | protocol = 0 , |
||
int | timeout_ms = -1 , |
||
ExceptionSink * | xsink = nullptr |
||
) |
connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors
name | the name or address of the host |
service | the port number or service name of the remote socket |
family | should be either AF_INET (for ipv4) or AF_INET6 (for ipv6) |
sock_type | the type of socket, normally SOCK_STREAM for tcp sockets or SOCK_DGRAM for udp sockets |
protocol | the protocol number, use 0 for the default |
timeout_ms | the timeout period in milliseconds |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectINET2SSL | ( | const char * | name, |
const char * | service, | ||
int | family, | ||
int | sock_type, | ||
int | protocol, | ||
int | timeout_ms, | ||
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink = nullptr |
||
) |
connects to an INET or INET6 socket by hostname and port number or service name and returns a status code, Qore-language exceptions are raised in the case of any errors
name | the name or address of the host |
service | the port number or service name of the remote socket |
family | should be either AF_INET (for ipv4) or AF_INET6 (for ipv6) |
sock_type | the type of socket, normally SOCK_STREAM for tcp sockets or SOCK_DGRAM for udp sockets |
protocol | the protocol number, use 0 for the default |
timeout_ms | the timeout period in milliseconds |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectINETSSL | ( | const char * | host, |
int | prt, | ||
int | timeout_ms, | ||
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
connects to an INET socket by hostname and port number, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
host | the name or IP address of the host |
prt | the port number of the remote socket |
timeout_ms | the timeout period in milliseconds |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectINETSSL | ( | const char * | host, |
int | prt, | ||
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
connects to an INET socket by hostname and port number, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
host | the name or IP address of the host |
prt | the port number of the remote socket |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectSSL | ( | const char * | name, |
int | timeout_ms, | ||
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINETSSL() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIXSSL() is called.
name | the name of the socket (either hostname:port or file name) |
timeout_ms | the timeout period in milliseconds |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectSSL | ( | const char * | name, |
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
connects to a socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::connectINETSSL() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::connectUNIXSSL() is called.
name | the name of the socket (either hostname:port or file name) |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectUNIX | ( | const char * | p, |
ExceptionSink * | xsink = nullptr |
||
) |
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors
p | the file name of the UNIX domain socket |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectUNIX | ( | const char * | p, |
int | socktype, | ||
int | protocol = 0 , |
||
ExceptionSink * | xsink = nullptr |
||
) |
connects to a UNIX domain socket and returns a status code, Qore-language exceptions are raised in the case of any errors
p | the file name of the UNIX domain socket |
socktype | the type of socket (SOCK_STREAM = tcp socket) |
protocol | the protocol for the socket (use 0 for default) |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectUNIXSSL | ( | const char * | p, |
int | socktype, | ||
int | protocol, | ||
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
p | the file name of the UNIX domain socket |
socktype | the type of socket (SOCK_STREAM = tcp socket) |
protocol | the protocol for the socket (use 0 for default) |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::connectUNIXSSL | ( | const char * | p, |
X509 * | cert, | ||
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
connects to a UNIX domain socket, negotiates an SSL connection, and returns a status code, Qore-language exceptions are raised in the case of any errors
p | the file name of the UNIX domain socket |
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if not 0, if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT bool QoreSocket::getAcceptAllCertificates | ( | ) | const |
returns the current value of the "accept all certificates" flag
DLLEXPORT int64 QoreSocket::getConnectionId | ( | ) | const |
returns a connection ID to help identifying when new connections are made
DLLEXPORT const QoreEncoding * QoreSocket::getEncoding | ( | ) | const |
returns the character encoding associated with this socket
DLLEXPORT QoreHashNode * QoreSocket::getPeerInfo | ( | ExceptionSink * | xsink | ) | const |
returns peer information for a connected socket
if the socket is not connected, a Qore-language exception is thrown
xsink | if an error occurs, the Qore-language exception information will be added here |
hostname:
the hostname of the remote end (if known or appropriate for the socket type)hostname_desc:
a descriptive string for the remote hostname (including the socket type - ie "ipv6[host]")address:
the address of the remote end - for UNIX sockets this is the file pathaddress_desc:
a descriptive string for the remote addressport:
the port number if knownfamily:
the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)familystr:
a string description of the address family ("ipv4", "ipv6", etc) DLLEXPORT QoreHashNode * QoreSocket::getPeerInfo | ( | ExceptionSink * | xsink, |
bool | host_lookup | ||
) | const |
returns peer information for a connected socket
if the socket is not connected, a Qore-language exception is thrown
xsink | if an error occurs, the Qore-language exception information will be added here |
host_lookup | do a host lookup (if this is false the "hostname" and "hostname_desc" are not present in the response hash) |
hostname:
the hostname of the remote end (if known or appropriate for the socket type, only performed if host_lookup is true)hostname_desc:
a descriptive string for the remote hostname (including the socket type - ie "ipv6[host]", only performed if host_lookup is true)address:
the address of the remote end - for UNIX sockets this is the file pathaddress_desc:
a descriptive string for the remote addressport:
the port number if knownfamily:
the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)familystr:
a string description of the address family ("ipv4", "ipv6", etc) DLLEXPORT QoreObject * QoreSocket::getRemoteCertificate | ( | ) | const |
returns a remote certificate if available
DLLEXPORT int QoreSocket::getSocket | ( | ) | const |
returns the file descriptor associated with this socket
DLLEXPORT QoreHashNode * QoreSocket::getSocketInfo | ( | ExceptionSink * | xsink | ) | const |
returns information for the current socket; the socket must be open
if the socket is not open, a Qore-language exception is thrown
xsink | if an error occurs, the Qore-language exception information will be added here |
hostname:
the hostname of the remote end (if known or appropriate for the socket type, only performed if host_lookup is true)hostname_desc:
a descriptive string for the remote hostname (including the socket type - ie "ipv6[host]", only performed if host_lookup is true)address:
the address of the local interface - for UNIX sockets this is the file pathaddress_desc:
a descriptive string for the local interfaceport:
the port number if knownfamily:
the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)familystr:
a string description of the address family ("ipv4", "ipv6", etc) DLLEXPORT QoreHashNode * QoreSocket::getSocketInfo | ( | ExceptionSink * | xsink, |
bool | host_lookup | ||
) | const |
returns information for the current socket; the socket must be open
if the socket is not open, a Qore-language exception is thrown
xsink | if an error occurs, the Qore-language exception information will be added here |
host_lookup | do a host lookup (if this is false the "hostname" and "hostname_desc" are not present in the response hash) |
hostname:
the hostname for the local interface (if known or appropriate for the socket type)hostname_desc:
a descriptive string for the local hostname (including the socket type - ie "ipv6[host]")address:
the address of the local interface - for UNIX sockets this is the file pathaddress_desc:
a descriptive string for the local interfaceport:
the port number if knownfamily:
the address family (ie AF_INET, AF_INET6, AF_UNIX, ...)familystr:
a string description of the address family ("ipv4", "ipv6", etc) DLLEXPORT const char * QoreSocket::getSSLCipherName | ( | ) | const |
returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none
DLLEXPORT const char * QoreSocket::getSSLCipherVersion | ( | ) | const |
returns the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none
DLLEXPORT int QoreSocket::getSslVerifyMode | ( | ) | const |
returns the SSL verification mode
mode
parameter of SSL_set_verify() for detailsDLLEXPORT bool QoreSocket::isDataAvailable | ( | ExceptionSink * | xsink, |
int | timeout_ms = 0 |
||
) | const |
returns true if data is available on the socket in the timeout period in milliseconds
The socket must be connected before this call is made. use a timeout of 0 to see if there is any data available on the socket
xsink | if an error occurs, the Qore-language exception information will be added here |
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
DLLEXPORT bool QoreSocket::isDataAvailable | ( | int | timeout_ms = 0 | ) | const |
returns true if data is available on the socket in the timeout period in milliseconds
The socket must be connected before this call is made. use a timeout of 0 to see if there is any data available on the socket
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
DLLEXPORT bool QoreSocket::isOpen | ( | ) | const |
returns true if the socket is open
DLLEXPORT bool QoreSocket::isSecure | ( | ) | const |
returns true if an SSL connection is active
DLLEXPORT bool QoreSocket::isWriteFinished | ( | ExceptionSink * | xsink, |
int | timeout_ms = 0 |
||
) | const |
returns true if all write data has been written within the timeout period in milliseconds
The socket must be connected before this call is made. use a timeout of 0 to receive an answer immediately
xsink | if an error occurs, the Qore-language exception information will be added here |
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
DLLEXPORT bool QoreSocket::isWriteFinished | ( | int | timeout_ms = 0 | ) | const |
returns true if all write data has been written within the timeout period in milliseconds
The socket must be connected before this call is made. use a timeout of 0 to receive an answer immediately
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
DLLEXPORT int QoreSocket::listen | ( | ) |
sets an open socket to the listening state
DLLEXPORT int QoreSocket::listen | ( | int | backlog | ) |
sets an open socket to the listening state
backlog | the size of the queue for pending connections |
DLLEXPORT QoreHashNode * QoreSocket::readHTTPChunkedBody | ( | int | timeout_ms, |
ExceptionSink * | xsink, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
receive a string message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count returned
The socket must be connected before this call is made. The message body is returned as a QoreStringNode in the "body" key, any footers read after the body are returned as the other hash keys in the hash.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
source | the event source code for socket events |
DLLEXPORT QoreHashNode * QoreSocket::readHTTPChunkedBodyBinary | ( | int | timeout_ms, |
ExceptionSink * | xsink, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
receive a binary message in HTTP chunked transfer encoding, caller owns QoreHashNode reference count returned
The socket must be connected before this call is made. The message body is returned as a BinaryNode in the "body" key, any footers read after the body are returned as the other hash keys in the hash.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
source | the event source code for socket events |
DLLEXPORT QoreHashNode * QoreSocket::readHTTPHeader | ( | ExceptionSink * | xsink, |
QoreHashNode * | info, | ||
int | timeout_ms, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
read and parse HTTP header, caller owns QoreHashNode reference count returned
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
info | the request-uri or response-uri is written to this hash if non-null; neither of these keys should be present in the hash before the call |
timeout_ms | in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
source | the event source code for socket events |
DLLEXPORT AbstractQoreNode * QoreSocket::readHTTPHeader | ( | int | timeout_ms, |
int * | prc, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
read and parse HTTP header, caller owns AbstractQoreNode reference count returned
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
prc | output parameter: 0 or -2: remote end closed the connection, -1: receive error, -3: timeout |
source | the event source code for socket events |
DLLEXPORT AbstractQoreNode * QoreSocket::readHTTPHeader | ( | QoreHashNode * | info, |
int | timeout_ms, | ||
int * | prc, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
read and parse HTTP header, caller owns AbstractQoreNode reference count returned
The socket must be connected before this call is made.
info | the request-uri or response-uri is written to this hash if non-null; neither of these keys should be present in the hash before the call |
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
prc | output parameter: 0 or -2: remote end closed the connection, -1: receive error, -3: timeout |
source | the event source code for socket events |
DLLEXPORT QoreStringNode * QoreSocket::readHTTPHeaderString | ( | ExceptionSink * | xsink, |
int | timeout_ms, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
read a HTTP header, caller owns QoreStringNode reference count returned
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
timeout_ms | in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
source | the event source code for socket events |
DLLEXPORT int QoreSocket::recv | ( | int | fd, |
qore_offset_t | size, | ||
int | timeout_ms | ||
) |
receive data on the socket and write it to a file descriptor
The socket must be connected before this call is made.
fd | the file descriptor to write to, must be already opened for writing |
size | the number of bytes to read from the socket, -1 to read until the socket is closed |
timeout_ms | timeout for socket I/O in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
DLLEXPORT int QoreSocket::recv | ( | int | fd, |
qore_offset_t | size, | ||
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
receive data on the socket and write it to a file descriptor
The socket must be connected before this call is made.
fd | the file descriptor to write to, must be already opened for writing |
size | the number of bytes to read from the socket, -1 to read until the socket is closed |
timeout_ms | timeout for socket I/O in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT QoreStringNode * QoreSocket::recv | ( | int | timeout_ms, |
ExceptionSink * | xsink | ||
) |
receive with a timeout value and return a QoreStringNode, caller owns the reference count returned
The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a QoreStringNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT QoreStringNode * QoreSocket::recv | ( | int | timeout_ms, |
int * | prc | ||
) |
receive with a timeout value and return a QoreStringNode, caller owns the reference count returned
The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a QoreStringNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
prc | output parameter: 0 for OK, not 0 for error |
DLLEXPORT QoreStringNode * QoreSocket::recv | ( | qore_offset_t | bufsize, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned
The socket must be connected before this call is made.
bufsize | number of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side |
timeout_ms | in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT QoreStringNode * QoreSocket::recv | ( | qore_offset_t | bufsize, |
int | timeout_ms, | ||
int * | prc | ||
) |
receive a certain number of bytes with a timeout value and return a QoreStringNode, caller owns the reference count returned
The socket must be connected before this call is made.
bufsize | number of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side |
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
prc | output parameter: 0 for OK, not 0 for error |
DLLEXPORT BinaryNode * QoreSocket::recvBinary | ( | int | timeout_ms, |
ExceptionSink * | xsink | ||
) |
receive with a timeout value and return a BinaryNode, caller owns the reference count returned
The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a BinaryNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT BinaryNode * QoreSocket::recvBinary | ( | int | timeout_ms, |
int * | prc | ||
) |
receive with a timeout value and return a BinaryNode, caller owns the reference count returned
The socket must be connected before this call is made. This call will read data, blocking according to the timeout value. Then all data available on the socket will be read and returned as a BinaryNode. As soon as the first timeout occurs, the data will be returned immediately without blocking.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
prc | output parameter: 0 for OK, not 0 for error |
DLLEXPORT BinaryNode * QoreSocket::recvBinary | ( | qore_offset_t | bufsize, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the reference count returned
The socket must be connected before this call is made.
bufsize | number of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side |
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT BinaryNode * QoreSocket::recvBinary | ( | qore_offset_t | bufsize, |
int | timeout_ms, | ||
int * | prc | ||
) |
receive a certain number of bytes with a timeout value and return a BinaryNode, caller owns the reference count returned
The socket must be connected before this call is made.
bufsize | number of bytes to read from the socket; if <= 0, read all data available from the socket until the socket is closed from the other side |
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
prc | output parameter: 0 for OK, not 0 for error |
DLLEXPORT int QoreSocket::recvi1 | ( | int | timeout_ms, |
char * | val | ||
) |
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi1 | ( | int | timeout_ms, |
char * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 1-byte signed integer from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvi2 | ( | int | timeout_ms, |
short * | val | ||
) |
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi2 | ( | int | timeout_ms, |
short * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 2-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvi2LSB | ( | int | timeout_ms, |
short * | val | ||
) |
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi2LSB | ( | int | timeout_ms, |
short * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 2-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvi4 | ( | int | timeout_ms, |
int * | val | ||
) |
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi4 | ( | int | timeout_ms, |
int * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 4-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvi4LSB | ( | int | timeout_ms, |
int * | val | ||
) |
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi4LSB | ( | int | timeout_ms, |
int * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 4-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvi8 | ( | int | timeout_ms, |
int64 * | val | ||
) |
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi8 | ( | int | timeout_ms, |
int64 * | val, | ||
ExceptionSink * | xsink | ||
) |
reads an 8-byte signed integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvi8LSB | ( | int | timeout_ms, |
int64 * | val | ||
) |
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvi8LSB | ( | int | timeout_ms, |
int64 * | val, | ||
ExceptionSink * | xsink | ||
) |
reads an 8-byte signed integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvu1 | ( | int | timeout_ms, |
unsigned char * | val | ||
) |
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvu1 | ( | int | timeout_ms, |
unsigned char * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 1-byte unsigned integer from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvu2 | ( | int | timeout_ms, |
unsigned short * | val | ||
) |
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvu2 | ( | int | timeout_ms, |
unsigned short * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 2-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvu2LSB | ( | int | timeout_ms, |
unsigned short * | val | ||
) |
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvu2LSB | ( | int | timeout_ms, |
unsigned short * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 2-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvu4 | ( | int | timeout_ms, |
unsigned int * | val | ||
) |
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvu4 | ( | int | timeout_ms, |
unsigned int * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 4-byte unsigned integer in MSB (Most Significant Byte first, big endian, network) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::recvu4LSB | ( | int | timeout_ms, |
unsigned int * | val | ||
) |
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
DLLEXPORT int64 QoreSocket::recvu4LSB | ( | int | timeout_ms, |
unsigned int * | val, | ||
ExceptionSink * | xsink | ||
) |
reads a 4-byte unsigned integer in LSB (Most Significant Byte first, little endian) format from the socket with a timeout value and returns the value read as an output parameter
The socket must be connected before this call is made.
timeout_ms | timeout in milliseconds, -1=never timeout, 0=do not block, return immediately if there is no data waiting |
val | output parameter: the integer value read from the file |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const BinaryNode * | msg | ) |
sends binary data on a connected socket
msg | the data to send |
DLLEXPORT int QoreSocket::send | ( | const BinaryNode * | msg, |
ExceptionSink * | xsink | ||
) |
sends binary data on a connected socket
msg | the data to send |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const BinaryNode * | msg, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends binary data on a connected socket
msg | the data to send |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const char * | buf, |
size_t | size | ||
) |
sends binary data on a connected socket
buf | the data to send |
size | the size of the data to send |
DLLEXPORT int QoreSocket::send | ( | const char * | buf, |
size_t | size, | ||
ExceptionSink * | xsink | ||
) |
sends binary data on a connected socket
buf | the data to send |
size | the size of the data to send |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const char * | buf, |
size_t | size, | ||
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends binary data on a connected socket
buf | the data to send |
size | the size of the data to send |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const QoreString * | msg, |
ExceptionSink * | xsink | ||
) |
sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary
msg | the string to send (must not be 0) |
xsink | if an error occurs in converting the string's character encoding or in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const QoreString * | msg, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary
msg | the string to send (must not be 0) |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in converting the string's character encoding or in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | const QoreStringNode & | msg, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends string data on a connected socket, converts the string encoding to the socket's encoding if necessary
msg | the string to send (must not be 0) |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in converting the string's character encoding or in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | int | fd, |
qore_offset_t | size, | ||
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends untranslated data from an open file descriptor
fd | a file descriptor, open for reading |
size | the number of bytes to send (-1 = send all until EOF) |
timeout_ms | a timeout in milliseconds for socket I/O operations |
xsink | if an I/O error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::send | ( | int | fd, |
qore_offset_t | size = -1 |
||
) |
sends untranslated data from an open file descriptor
fd | a file descriptor, open for reading |
size | the number of bytes to send (-1 = send all until EOF) |
DLLEXPORT int QoreSocket::sendHTTPMessage | ( | const char * | method, |
const char * | path, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
send an HTTP request message on the socket
The socket must be connected before this call is made.
method | the method string to use in the header - no validity checking is made on this string |
path | the path string to use in the header, if the path is empty then '/' is sent |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
DLLEXPORT int QoreSocket::sendHTTPMessage | ( | ExceptionSink * | xsink, |
QoreHashNode * | info, | ||
const char * | method, | ||
const char * | path, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source, | ||
int | timeout_ms | ||
) |
send an HTTP request message on the socket with a timeout value
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
info | if not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call |
method | the method string to use in the header - no validity checking is made on this string |
path | the path string to use in the header, if the path is empty then '/' is sent |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
DLLEXPORT int QoreSocket::sendHTTPMessage | ( | ExceptionSink * | xsink, |
QoreHashNode * | info, | ||
const char * | method, | ||
const char * | path, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
send an HTTP request message on the socket
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
info | if not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call |
method | the method string to use in the header - no validity checking is made on this string |
path | the path string to use in the header, if the path is empty then '/' is sent |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
DLLEXPORT int QoreSocket::sendHTTPMessage | ( | QoreHashNode * | info, |
const char * | method, | ||
const char * | path, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
send an HTTP request message on the socket
The socket must be connected before this call is made.
info | if not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call |
method | the method string to use in the header - no validity checking is made on this string |
path | the path string to use in the header, if the path is empty then '/' is sent |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
DLLEXPORT int QoreSocket::sendHTTPMessageWithCallback | ( | ExceptionSink * | xsink, |
QoreHashNode * | info, | ||
const char * | method, | ||
const char * | path, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const ResolvedCallReferenceNode & | send_callback, | ||
int | source, | ||
int | timeout_ms | ||
) |
send an HTTP request message on the socket with a timeout value with a chunked message body using a calback
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
info | if not null, the request-uri and response-uri will be written to this hash, neither of these keys should be set before this call |
method | the method string to use in the header - no validity checking is made on this string |
path | the path string to use in the header, if the path is empty then '/' is sent |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
send_callback | the callback for the chunked message body |
source | the event source code for socket events |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
DLLEXPORT int QoreSocket::sendHTTPResponse | ( | ExceptionSink * | xsink, |
int | code, | ||
const char * | desc, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source, | ||
int | timeout_ms | ||
) |
send an HTTP response message on the socket
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
code | the HTTP response code |
desc | the text description for the response code |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
DLLEXPORT int QoreSocket::sendHTTPResponse | ( | ExceptionSink * | xsink, |
int | code, | ||
const char * | desc, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
send an HTTP response message on the socket
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
code | the HTTP response code |
desc | the text description for the response code |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
DLLEXPORT int QoreSocket::sendHTTPResponse | ( | ExceptionSink * | xsink, |
QoreHashNode * | info, | ||
int | code, | ||
const char * | desc, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source, | ||
int | timeout_ms | ||
) |
send an HTTP response message on the socket
The socket must be connected before this call is made.
xsink | if an error occurs, the Qore-language exception information will be added here |
info | if not null, the response-uri will be written to this hash, neither of these keys should be set before this call |
code | the HTTP response code |
desc | the text description for the response code |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
DLLEXPORT int QoreSocket::sendHTTPResponse | ( | int | code, |
const char * | desc, | ||
const char * | http_version, | ||
const QoreHashNode * | headers, | ||
const void * | data, | ||
size_t | size, | ||
int | source = QORE_SOURCE_SOCKET |
||
) |
send an HTTP response message on the socket
The socket must be connected before this call is made.
code | the HTTP response code |
desc | the text description for the response code |
http_version | should be either "1.0" or "1.1" |
headers | a hash of headers to send (key: value) |
data | optional message body to send (may be 0) |
size | the length of the message body (may be 0) |
source | the event source code for socket events |
DLLEXPORT int QoreSocket::sendi1 | ( | char | i | ) |
sends a 1-byte binary integer data to a connected socket
The socket must be connected before this call is made.
i | the 1-byte integer to send through the socket |
DLLEXPORT int QoreSocket::sendi1 | ( | char | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends a 1-byte binary integer data to a connected socket
The socket must be connected before this call is made.
i | the 1-byte integer to send through the socket |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::sendi2 | ( | short | i | ) |
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
DLLEXPORT int QoreSocket::sendi2 | ( | short | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends a 2-byte (16bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::sendi2LSB | ( | short | i | ) |
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
DLLEXPORT int QoreSocket::sendi2LSB | ( | short | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends a 2-byte (16bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::sendi4 | ( | int | i | ) |
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
DLLEXPORT int QoreSocket::sendi4 | ( | int | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends a 4-byte (32bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::sendi4LSB | ( | int | i | ) |
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
DLLEXPORT int QoreSocket::sendi4LSB | ( | int | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends a 4-byte (32bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::sendi8 | ( | int64 | i | ) |
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
DLLEXPORT int QoreSocket::sendi8 | ( | int64 | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends an 8-byte (64bit) binary integer in MSB (Most Significant Byte first, big endian, network) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::sendi8LSB | ( | int64 | i | ) |
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
DLLEXPORT int QoreSocket::sendi8LSB | ( | int64 | i, |
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
sends an 8-byte (64bit) binary integer in LSB (Least Significant Byte first, little endian) format through a connected socket
The socket must be connected before this call is made.
i | the integer to write to the file |
timeout_ms | the maximum amount of time the socket can block on a single send as an integer in milliseconds |
xsink | if an error occurs in socket communication, the Qore-language exception information will be added here |
DLLEXPORT void QoreSocket::setEncoding | ( | const QoreEncoding * | id | ) |
sets the character encoding for strings sent and received with this socket
id | the character encoding for strings sent and received with this socket |
DLLEXPORT void QoreSocket::setSslVerifyMode | ( | int | mode | ) |
sets the SSL verification mode
If no SSL connection is in place, then the mode is saved for use with future SSL connections.
mode | see the mode parameter of SSL_set_verify() for details |
DLLEXPORT int QoreSocket::shutdown | ( | ) |
calls shutdown on the socket
shuts down the socket for reading and writing, after this call further sends and receives are disallowed until the socket is reopened.
DLLEXPORT int QoreSocket::shutdownSSL | ( | ExceptionSink * | xsink | ) |
shuts down an active SSL connection
called implicitly by QoreSocket::close()
DLLEXPORT AbstractPollState * QoreSocket::startConnect | ( | ExceptionSink * | xsink, |
const char * | name | ||
) |
Starts a non-blocking connection to a socket and returns a status code.
If "name" has a ':' in it; it's assumed to be a hostname:port specification and QoreSocket::startConnectINET() is called. Otherwise "name" is assumed to be a file name for a UNIX domain socket and QoreSocket::startConnectUNIX() is called.
xsink | if an error occurs, the Qore-language exception information will be added here |
name | the name of the socket (either hostname:port or file name) |
DLLEXPORT AbstractPollState * QoreSocket::startRecv | ( | ExceptionSink * | xsink, |
size_t | size | ||
) |
Starts a non-blocking receive operation on a connected socket.
xsink | if an error occurs, the Qore-language exception information will be added here |
size | the size of the data to read, must be > 0 |
DLLEXPORT AbstractPollState * QoreSocket::startRecvUntilBytes | ( | ExceptionSink * | xsink, |
const char * | pattern, | ||
size_t | size | ||
) |
Starts a non-blocking receive operation on a connected socket.
xsink | if an error occurs, the Qore-language exception information will be added here |
pattern | the bytes to expect that indicate the end of the data, must stay valid for the lifetime of the AbstractPollState object returned |
size | the size of pattern in bytes |
DLLEXPORT AbstractPollState * QoreSocket::startSend | ( | ExceptionSink * | xsink, |
const char * | data, | ||
size_t | size | ||
) |
Starts a non-blocking send operation on a connected socket.
xsink | if an error occurs, the Qore-language exception information will be added here |
data | the data to send, must stay valid for the lifetime of the AbstractPollState object returned |
size | the size of the data to send |
DLLEXPORT AbstractPollState * QoreSocket::startSslConnect | ( | ExceptionSink * | xsink, |
X509 * | cert = nullptr , |
||
EVP_PKEY * | pkey = nullptr |
||
) |
Starts a non-blocking upgrade to an SSL connection on a connected client connection.
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::upgradeClientToSSL | ( | X509 * | cert, |
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
negotiates an SSL connection from the client side
The socket must be connected before this call is made.
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::upgradeClientToSSL | ( | X509 * | cert, |
EVP_PKEY * | pkey, | ||
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
negotiates an SSL connection from the client side
The socket must be connected before this call is made.
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
timeout_ms | timeout in milliseconds, -1 = never timeout |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::upgradeServerToSSL | ( | X509 * | cert, |
EVP_PKEY * | pkey, | ||
ExceptionSink * | xsink | ||
) |
negotiates an SSL connection from the client side
The socket must be connected before this call is made.
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
xsink | if an error occurs, the Qore-language exception information will be added here |
DLLEXPORT int QoreSocket::upgradeServerToSSL | ( | X509 * | cert, |
EVP_PKEY * | pkey, | ||
int | timeout_ms, | ||
ExceptionSink * | xsink | ||
) |
negotiates an SSL connection from the client side
The socket must be connected before this call is made.
cert | the X509 certificate to use for the connection, may be 0 if no certificate should be used |
pkey | the private key to use for the connection, may be 0 if no private key should be used |
timeout_ms | timeout in milliseconds, -1 = never timeout |
xsink | if an error occurs, the Qore-language exception information will be added here |