SET IP
SET IP
The shell ip item implements the following commands:
CLOSE
SET ip CLOSE
Close open connections. Connections can be reconnected using the CONNECT
command.
CONNECT
SET ip CONNECT [ raddr rport ] [ /u ]
Open a connection to a remote server. If the connection is accepted, the CONNECTED
message is sent to the shell.
- ip
- The name of the ip item instance.
- raddr
- The remote ip address to connect to. If raddr is not specified, the raddr specified by the last
CONNECT
command is used.
- rport
- The remote port to connect to. If rport is not specified, the rport specified by the last
CONNECT
command is used.
- /u
- If specified, the UDP protocol is used for the connection. Otherwise the TCP protocol is used.
Example:
#raddr := set '192.168.1.25'#rport := '7000'#ip := new ip *$#ip connect $#raddr $#rport /u
LISTEN
SET ip LISTEN laddr lport [ /u ]
- ip
- The name of the ip item instance.
- laddr
- The local ip address to listen for connections on. If an asterisk is specified, the ip item listens on all local network interfaces.
- lport
- The local port to listen for connections on.
- /u
- If specified, the UDP protocol is used for the connection. Otherwise the TCP protocol is used.
RECEIVE
SET ip RECEIVE [ table|variable [ field ] ] // client
SET ip RECEIVE socketId [ table|variable [ field ] ] // server
The ip item's RECEIVE
command retrieves the next message from the queue of received messages. If successful, the local variable #ipreceive
retrieved data.
- ip
- The name of an ip item instance.
- socketId
- The id of the socket to retrieve the message from. This parameter must be specified if the ip instance is acting as a server.
- table
- A table item to store the received data in. This should be a simple table for a string message and an parameter table for a numeric data message. Note that this parameter is optional. If you do not specify a table, a table of the correct type is created for you. If the command is successful, the local variable
#ipreceive
contains the name of the table item containing the received data.
- variable
- The name of a variable to store the table name in.
- field
- If a table parameter table is specified, then the first field to retrieve data into may also be specified. If no field is specified, the first field is used.
RESET
SET ip RESET
Close open connections. Connections can be reconnected using the CONNECT
command.
SEND
SET ip SEND [ socketId ] table|string [ /p ] [ /m ] [ /u ]
The SEND
command sends data to a remote host using an existing connection.
- socketId
- If this ip instance is acting as a server, then a socket id must be specified on which to send the data.
- table
- A table item containing the data to send. The type of data you can send depends on the protocol.
- string
- /p=o|s|a|u
- Specify the data protocol. The following protocols are supported:
- o - Open Sound Control (OSC) protocol
- s - STx protocol
- a - ASCII text
- u - Unicode text
- If no protocol is specified, the STx protocol is used by default.
- /m
- If specified, a SENT message is sent when sending is completed. This is not the same as the
READYTOSEND
message.
- /u
- If specified, strings are sent as Unicode. Otherwise they are sent as ASCII.
Example:
#ip := new ip *$#ip connect localhost 5000// send 'hello' as ASCII text$#ip send 'hello' /p=a