NetAddr:
Filter:
Classes | Control | External Control > OSC

NetAddr : Object

network address
Source: NetAddr.sc
Subclasses: BundleNetAddr

Class Methods

NetAddr.new(hostname, port)

create new net address.

NOTE: To send messages internally, loopback IP is used: "127.0.0.1"

Arguments:

hostname

a String, either an IP number (e.g. "192.168.34.56") or a hostname such as "otherHost.local".

port

a port number, like 57110.

NetAddr.fromIP(addr, port)

create new net address using an integer IP number.

NetAddr.langPort

Get the port sclang is currently listening on (may change after a recompile).

NetAddr.localIP(network)

Get the local IP address as a String.

Arguments:

network

An optional IP string to select a particular network. This might be necessary if your machine is connected to multiple networks. Typically, you would use the IP address of the router, but it can really be any address within the network.

NetAddr.localEndPoint(port, network)

Get a NetAddr with the local IP address and a user provided port number.

Arguments:

port

The port number. If omitted, the sclang port is used.

network

An optional IP string to select a particular network. See also *localIP.

NetAddr.localAddr

Get a NetAddr which corresponds to localhost and the port sclang is listening on.

NetAddr.disconnectAll

close all TCP connections.

NetAddr.broadcastFlag

NetAddr.broadcastFlag = flag: true

Get or set the broadcast flag (whether or not broadcast messages can be sent).

NetAddr.localIPs(family: 'all')

Get all local IP addresses (NICs) on this computer.

Arguments:

family

A Symbol that specifies the desired address family.

allall addresses
ipv4only IPv4 addresses
ipv6only IPv6 addresses

Returns:

An Array containing all local IP addresses of the desired family.

NetAddr.matchLangIP(ipstring)

Test an IP address to see if it matches any local IP address. See also *localIPs.

Arguments:

ipstring

A String to test containing an IP number in dot decimal notation (e.g. "192.168.34.56").

Returns:

A Boolean indicating whether a match was found.

NetAddr.connections

Returns:

A copy of the IdentityDictionary with all open TCP connections.

Inherited class methods

Undocumented class methods

NetAddr.useDoubles = flag: false

Instance Methods

.sendMsg( ... args)

Convert the argument list to an OSC message and send it to the NetAddr without a timestamp. The first argument is the OSC address, and the remaining arguments are the arguments in the OSC message. If you leave off the initial "/" in the OSC address, one will be prepended. The technical details of how sclang objects are converted to OSC messages is given in the OSC Communication helpfile.

.sendBundle(time ... args)

send a bundle with timestamp to the addr.

.sendRaw(rawArray)

send a raw message without timestamp to the addr.

.connect(disconnectHandler)

open TCP connection.

Arguments:

disconnectHandler

called when the connection is closed (either by the client or by the server).

.disconnect

close TCP connection.

.ip

returns the ip number (as a String).

.isLocal

Test if this NetAddr ip number matches that of one of this hosts NICs, or the loopback address.

Returns:

Inherited instance methods

Undocumented instance methods

==(that)

.addr

.hasBundle

.hash

.hostname

.hostname = inHostname

.isConnected

.makeSyncResponder(condition)

.matches(that)

.port

.port = value

.sendClumpedBundles(time ... args)

.sendStatusMsg

.socket

.sync(condition, bundles, latency)

.tryConnectTCP(onComplete, onFailure, maxAttempts: 10)

.tryDisconnectTCP(onComplete, onFailure)

Examples