OPEN.SOCKET() |
![]() ![]() ![]() |
The OPEN.SOCKET() function opens a data socket for an outgoing connection.
Format
OPEN.SOCKET(addr, port, flags)
where
The OPEN.SOCKET() function opens a connection to the server with the given address and port number.
If the action is successful, the function returns a socket variable that can be used to read and write data using the READ.SOCKET() and WRITE.SOCKET() functions. The STATUS()function will return zero.
If the socket cannot be opened, the STATUS() function will return an error code that can be used to determine the cause of the error.
Example
SKT = OPEN.SOCKET("193.118.13.14", 3000, SKT$BLOCKING) IF STATUS() THEN STOP 'Cannot open socket' N = WRITE.SOCKET(SKT, DATA, 0, 0) CLOSE.SOCKET SKT
This program fragment opens a connection to port 3000 of IP address 193.118.13.14, sends the data in DATA and then closes the socket.
See also: ACCEPT.SOCKET.CONNECTION, CLOSE.SOCKET, CREATE.SERVER.SOCKET(), READ.SOCKET(), SERVER.ADDR(), SET.SOCKET.MODE(), SOCKET.INFO(), WRITE.SOCKET() |