# Io Reference

Networking / DistributedObjects / DOConnection

The DOConnection object is useful for communicating with remote servers in a way that makes it look just like the sending of local messages. Proxies are automatically created on either side for passed objects, with the exception of strings and numbers, which are passed by value. Example:

    con := DOConnection clone setHost("127.0.0.1") setPort(8456) connect
    result := con serverObject test(1)
    writeln(result)
    r := result at(0)
    writeln(r)
    r := result at(1)
    writeln(r)

Implementation Notes:

The format of the Distributed Objects message is a list of NullCharacter terminated strings in one of these two formats:

Send message format:

    s NullCharacter targetId NullCharacter messageName NullCharacter argCount NullCharacter argType NullCharacter argValue NullCharacter (next arg type and value, etc)

Reply message format:

    r NullCharacter argType NullCharacter argvalue NullCharacter

If the argument is not a String, Number or nil then: If it is local to the sender, the type is RemoteObject. If it is a proxy to a remote object, the type is LocalObject. This isn't optimized yet.

close

Close the connection, if it is open. Returns self.
connect

Connect to the remote DOServer. Returns self or an Error, if one occurs.
host

Returns the host ip.
port

Returns the port.
serverObject

A handle to the remote DOServer's root object. Returns result from server or an Error, if one occurs.
setHost(ipString)

Sets the host ip to connect to. Returns self or an Error, if one occurs.
setPort(portNumber)

Sets the port number to connect to. Returns self.