UXN NETWORKING USING MULTIPLEXED IO Each message type consists of a single ASCII mode character, then one string of binary data. Any byte other than NUL (\0) is valid to use as data in these protocols. OUTPUT CH MESSAGE DESCRIPTION listen @ {addr}/{port}\0 listen to local {addr} on {port} open ^ {id}/{addr}/{port}\0 label connection to remote {addr} on {port} as {id} close ! {id}\0 close connection to remote {id} send > {id}/{data}\0 send {data} to remote {id} INPUT CH MESSAGE DESCRIPTION started $ {id}/{addr}/{port}\0 note connection from {addr} and {port} labelled as {id} ended # {id}\0 note end of connection labelled as {id} receive < {id}/{data}\0 receive {data} from remote {id} error * {msg}\0 error described by {msg} Addresses are either DNS hostnames, IPv4 addresses, or IPv6 addresses. URLs and URIs are not allowed (e.g. / should not appear in them). The {id} may contain any characters other than '/' or NUL (\0). Clients initiating a connection may choose any {id} they wish. Servers receiving a connection will have an {id} automatically-generated. The {id} will be unique at any given time but may be reused later after a connection is closed. Labels are not shared between the client and the server (e.g. a client may label a connection as "game" but the server might see the client's connection labelled as "client-3"). The maximum size allowed for any message is 4096 bytes, including the mode character and terminating NUL. The maximum size for any {id} is 8 bytes. The maximum size of {addr} is 253 bytes (the maximum size allowed by DNS). NOTE: clients should be prepared to read up to 4096 bytes but are only allowed to send up to 4080 bytes of data in > messages. This leaves extra room for receivers with a longer {id} than used by the sender. Messages are interpreted by a sidecar program which handles TCP/IP networking and maintaining connections. This protocol is not designed to be compatible with any other networking protocol. EXAMPLE SESSION Here's an example transcript from a hypothetical echo service. ACTOR ACTION MESSAGE EFFECT server writes @127.0.0.1/9999\0 opens port 9999 at 127.0.0.1 server reads $/127.0.0.1/9999\0 confirms service is listening client writes ^srv/127.0.0.1/9999\0 connects to server (id=srv) client reads $srv/127.0.0.1/9999\0 confirms client is connected server reads $001/127.0.0.1/9999\0 notified client is connected (id=001) client writes >srv/hello world\0 sends "hello world" to server server reads <001/hello world\0 server reads message server writes >001/hello world\0 server echoes message back client reads