The library socket allows to create socket objects and keep communications through this protocol.
The socket remains open during the life of a function or until its closure is indicated through the close command.
Therefore, a socket is not returnable from a function because the receiver will obtain a closed socket.
1 socket
Opens a TCP connection with the host indicated in the indicated port. With this tag an object type socket is created and then it is used to communicate as with the host. Any error with the creation of the communication channel or if the timeout is exceeded, it causes an exception.
<socket
host='host'
port='port'
timeout='timeout'
/>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Ahost | string | Name or IP server which will receive the request. The server has a service being executed in a port, through which the connection will be established via socket. | |||
Aport | number | Port in which the service is running. | |||
Atimeout | string | Time expressed in millliseconds, after which if no response has been received, the request is canceled. |
Returns | |
---|---|
Type | Description |
socket | Socket type object. |
Example
The following example shows how a connection to the host w2ksrv1 is open.
Copy
<xsql-script name='socket'> <body> <!-- open LPR client --> <set name='s'> <socket host='w2ksrv1' port='515' timeout='5000' /> </set> <!-- get queue state --> <socket.out.write> <s /> <byte>4</byte> </socket.out.write> </body> </xsql-script>