Qore supports a simple event-handling mechanism to provide notification and details of socket and network events in higher-level classes. Classes curerntly supporting events are the Socket, HTTPClient, and FtpClient classes.
See Event Constants for a list of all event constants; details about each event are documented in the following sections.
Event information is placed on the event queue (which must be a Queue object) in the form of a hash. Each event has at least the following keys:
Table 2.96. Event Hash Common Keys
Key | Value |
---|---|
| This key holds the event code; see information for individual events in the following sections |
| This key holds the event source code |
| The value of this key is a unique integer that can be used to uniquely identify the object generating the event. |
EVENT_PACKET_READ
SOURCE_SOCKET
This event is raised immediately after a network packet is received. The event hash contains the following keys:
Table 2.97. EVENT_PACKET_READ
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| The number of bytes read in the packet. |
| The total number of bytes read in the read loop. |
[ | The total number of bytes to read in the read loop (this key is only present if the total number of bytes to read is known). |
EVENT_PACKET_SENT
SOURCE_SOCKET
This event is raised immediately after a network packet is sent. The event hash contains the following keys:
Table 2.98. EVENT_PACKET_SENT
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| The file descriptor number of the socket. |
| The number of bytes sent in the packet. |
| The total number of bytes sent in the send loop. |
| The total number of bytes to send in the send loop. |
EVENT_HTTP_CONTENT_LENGTH
SOURCE_HTTPCLIENT
This event is raised immediately after an HTTP header is received containing a content length header line, but before the message body is received. The event hash contains the following keys:
Table 2.99. EVENT_HTTP_CONTENT_LENGTH
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| The number of bytes given for the content length. |
EVENT_HTTP_CHUNKED_START
SOURCE_HTTPCLIENT
This event is raised after receiving an HTTP header with Transfer-Encoding
set to chunked
and before the chunked data is read. The event hash contains the following keys:
Table 2.100. EVENT_HTTP_CHUNKED_START
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
EVENT_HTTP_CHUNKED_END
SOURCE_HTTPCLIENT
This event is raised after all chunked data is read from the socket. The event hash contains the following keys:
Table 2.101. EVENT_HTTP_CHUNKED_END
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
EVENT_HTTP_REDIRECT
SOURCE_HTTPCLIENT
This event is raised after a redirect response is received from an HTTP server. The event hash contains the following keys:
Table 2.102. EVENT_HTTP_REDIRECT
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| The redirect location given by the HTTP server |
[ | Any status message sent by the HTTP server; if no message was sent, then this key will not be present in the event hash. |
EVENT_CHANNEL_CLOSED
SOURCE_SOCKET
This event is raised immediately after the socket is closed. The event hash contains the following keys:
Table 2.103. EVENT_CHANNEL_CLOSED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
EVENT_DELETED
SOURCE_SOCKET
This event is raised when the socket object is deleted. The event hash contains the following keys:
Table 2.104. EVENT_DELETED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
EVENT_FTP_SEND_MESSAGE
SOURCE_FTPCLIENT
This event is raised immediately before a message is sent on the FTP control channel. The event hash contains the following keys:
Table 2.105. EVENT_FTP_SEND_MESSAGE
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| A string giving the FTP command sent (ex: |
[ | The argument to the command; if no argument is sent, then this key will not be present. |
EVENT_FTP_MESSAGE_RECEIVED
SOURCE_FTPCLIENT
This event is raised immediately after a message is received on the FTP control channel. The event hash contains the following keys:
Table 2.106. EVENT_FTP_MESSAGE_RECEIVED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| A string giving the FTP command sent (ex: |
[ | The argument to the command; if no argument is sent, then this key will not be present. |
EVENT_HOSTNAME_LOOKUP
SOURCE_SOCKET
This event is raised immediately before a hostname lookup is made. The event hash contains the following keys:
Table 2.107. EVENT_HOSTNAME_LOOKUP
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| A string giving the name to be looked up. |
EVENT_HOSTNAME_RESOLVED
SOURCE_SOCKET
This event is raised immediately after a successful hostname resolution. The event hash contains the following keys:
Table 2.108. EVENT_HOSTNAME_RESOLVED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| A string giving the network address the name was resolved to. |
EVENT_HTTP_SEND_MESSAGE
SOURCE_HTTPCLIENT
or SOURCE_SOCKET
This event is raised immediately before an HTTP message is sent. The event hash contains the following keys:
Table 2.109. EVENT_HTTP_SEND_MESSAGE
Event Hash
Key | Value |
---|---|
|
|
|
|
| The first string in the HTTP message (ex: |
| A hash of all headers to send in the message. |
EVENT_HTTP_MESSAGE_RECEIVED
SOURCE_HTTPCLIENT
or SOURCE_SOCKET
This event is raised immediately after an HTTP message is received. The event hash contains the following keys:
Table 2.110. EVENT_HTTP_MESSAGE_RECEIVED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A hash of all headers received in the message, plus the following headers giving additional information about the message: |
EVENT_HTTP_FOOTERS_RECEIVED
SOURCE_HTTPCLIENT
This event is raised immediately after HTTP footers are received after receiving chunked data. The event hash contains the following keys:
Table 2.111. EVENT_HTTP_FOOTERS_RECEIVED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A hash of all footers received in the message. |
EVENT_HTTP_CHUNKED_DATA_RECEIVED
SOURCE_HTTPCLIENT
This event is raised immediately after chunked data is received. The event hash contains the following keys:
Table 2.112. EVENT_HTTP_CHUNKED_DATA_RECEIVED
Event Hash
Key | Value |
---|---|
|
|
|
|
| An integer giving the number of bytes read in the chunk. |
| An integer giving the total number of bytes of chunked data read in the current message. |
EVENT_HTTP_CHUNK_SIZE
SOURCE_HTTPCLIENT
This event is raised immediately after chunk information is received providing the size of the next chunk. The event hash contains the following keys:
Table 2.113. EVENT_HTTP_CHUNK_SIZE_RECEIVED
Event Hash
Key | Value |
---|---|
|
|
|
|
| An integer giving the number of bytes in the next chunk. |
| An integer giving the total number of bytes of chunked data read in the current message. |
EVENT_CONNECTING
SOURCE_SOCKET
This event is raised immediately before a socket connection is attempted. The event hash contains the following keys:
Table 2.114. EVENT_CONNECTING
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| The type of address for the socket; one of the Network Address Constants. |
| The target address for the connection. |
[ | The target port for the connection; if not applicable for the address family then this hash key is not included. |
EVENT_CONNECTED
SOURCE_SOCKET
This event is raised immediately after a socket connection is established. The event hash contains the following keys:
Table 2.115. EVENT_CONNECTED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
EVENT_START_SSL
SOURCE_SOCKET
This event is raised immediately before SSL negotiation is attempted. The event hash contains the following keys:
Table 2.116. EVENT_START_SSL
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
EVENT_SSL_ESTABLISHED
SOURCE_SOCKET
This event is raised immediately after SSL negotiation has been successfully established. The event hash contains the following keys:
Table 2.117. EVENT_SSL_ESTABLISHED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the socket object. |
| A string giving the name of the cipher algorithm used for the connection. |
| A string giving the version of the cipher algorithm used for the connection. |
EVENT_OPEN_FILE
SOURCE_FILE
This event is raised immediately before a file is opened. The event hash contains the following keys:
Table 2.118. EVENT_OPEN_FILE
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the file object. |
| The file's name. |
| The flags used to open the file. |
| The mode to open the file with. |
| The character encoding given used for reading from or writing to the file. |
EVENT_FILE_OPENED
SOURCE_FILE
This event is raised immediately after a file has been successfully opened. The event hash contains the following keys:
Table 2.119. EVENT_FILE_OPENED
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the file object. |
| The file's name. |
| The flags used to open the file. |
| The mode to open the file with. |
| The character encoding given used for reading from or writing to the file. |
EVENT_DATA_READ
SOURCE_FILE
This event is raised immediately after data is read from a file. The event hash contains the following keys:
Table 2.120. EVENT_DATA_READ
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the file object. |
| The number of bytes read from the file. |
| The total number of bytes read in the read loop. |
| The total number of bytes to read in the read loop. |
EVENT_DATA_WRITTEN
SOURCE_FILE
This event is raised immediately after data is written from a file. The event hash contains the following keys:
Table 2.121. EVENT_DATA_WRITTEN
Event Hash
Key | Value |
---|---|
|
|
|
|
| A unique integer ID for the file object. |
| The number of bytes written to the file. |
| The total number of bytes written in the write loop. |
| The total number of bytes to write in the write loop. |