WRITE.SOCKET() |
![]() ![]() ![]() |
The WRITE.SOCKET() function writes data to a socket opened with ACCEPT.SOCKET.CONNECTION() or OPEN.SOCKET().
Format
WRITE.SOCKET(skt, data, flags, timeout)
where
If neither blocking flag is given, the blocking mode set when the socket was opened is used.
The WRITE.SOCKET() function writes the given data and returns the number of bytes written. If non-blocking mode is used or a timeout occurs, this byte count may be less than the length of the data. The remaining data can be written with a subsequent call to WRITE.SOCKET() when buffer space becomes available.
The STATUS() function returns zero if the action is successful, or a non-zero error code if an error occurs. A timeout will return an error code of ER$TIMEOUT as defined in the SYSCOM ERR.H record.
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(), OPEN.SOCKET(), READ.SOCKET(), SERVER.ADDR(), SET.SOCKET.MODE(), SOCKET.INFO() |