OPEN.SOCKET() |
|
|
The OPEN.SOCKET() function opens a data socket for an outgoing connection.
Format
OPEN.SOCKET(addr, port, flags {, timeout})
where
Socket type, one of:
Protocol, one of:
Blocking mode, one of:
The OPEN.SOCKET() function opens a connection to the server with the given address and port number.
For Unix domain sockets, the addr argument is the pathname of the socket connection and the port and timeout arguments are ignored.
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, possibly in conjunction with OS.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: Using Socket Connections, ACCEPT.SOCKET.CONNECTION, CLOSE.SOCKET, CREATE.SERVER.SOCKET(), READ.SOCKET(), SELECT.SOCKET(), SERVER.ADDR(), SET.SOCKET.MODE(), SOCKET.INFO(), WRITE.SOCKET() |