Unix Functions
The following routines are available when importing the librxunix.so library with
CALL import "librxunix.so".
CHDIR([dir])
change current directory to dir and return the current working
directory
| say chdir()
|
| call chdir "/home"
|
LISTEN(port)
Prepares a TCP/IP socket connection for listening on port.
Returns the socket descriptor id.
RECV(fd [,length])
Receives data through TCP/IP from socket descriptor fd of length
length. If length is not specified then it returns all
available data from the socket.
| say recv(fd)
|
| say recv(fd,10) | /* return 10 bytes */
|
SEND(fd, data)
Sends the data to socket fd. It returns the number
| say send(fd,"Hello world")
|
SLEEP(time [,"U","S","M","H","D"])
Call the system sleep function for a period of time
with units:
| Options |
| Us | micro seconds |
| Second | default |
| Minutes | |
| Hours | |
| Days | |
| call sleep 5 | /* sleep 5s */
|
| call sleep 1000,'u' | /* sleep 1ms */
|
SOCKET(host,port)
return the socket descriptor after opening the TCP/IP port on host
for communication. -1 on error
| fd = socket('localhost',1234)
|
| fd = socket('127.0.0.1',5678)
|
SOCKETCLOSE(fd)
close socket fd