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.


The following example shows how a connection to the host w2ksrv1 is open.

<xsql-script name='socket'>
        <!-- open LPR client -->

        <set name='s'>
            <socket host='w2ksrv1' port='515' timeout='5000' />

        <!-- get queue state -->

            <s />