forked from processing/processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOSCPort.java
More file actions
84 lines (72 loc) · 1.79 KB
/
Copy pathOSCPort.java
File metadata and controls
84 lines (72 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright (C) 2003-2006, C. Ramakrishnan / Illposed Software.
* All rights reserved.
*
* This code is licensed under the BSD 3-Clause license.
* See file LICENSE (or LICENSE.html) for more information.
*/
package com.illposed.osc;
import java.net.DatagramSocket;
/**
* OSCPort is an abstract superclass, to send OSC messages,
* use {@link OSCPortOut}.
* To listen for OSC messages, use {@link OSCPortIn}.
*
* @author Chandrasekhar Ramakrishnan
*/
public abstract class OSCPort {
private DatagramSocket socket;
private int port;
public static final int DEFAULT_SC_OSC_PORT = 57110;
public static final int DEFAULT_SC_LANG_OSC_PORT = 57120;
protected OSCPort(DatagramSocket socket, int port) {
this.socket = socket;
this.port = port;
}
/**
* The port that the SuperCollider <b>synth</b> engine
* usually listens to.
* @see #DEFAULT_SC_OSC_PORT
*/
public static int defaultSCOSCPort() {
return DEFAULT_SC_OSC_PORT;
}
/**
* The port that the SuperCollider <b>language</b> engine
* usually listens to.
* @see #DEFAULT_SC_LANG_OSC_PORT
*/
public static int defaultSCLangOSCPort() {
return DEFAULT_SC_LANG_OSC_PORT;
}
/**
* Returns the socket associated with this port.
* @return this ports socket
*/
protected DatagramSocket getSocket() {
return socket;
}
/**
* Returns the port number associated with this port.
* @return this ports number
*/
protected int getPort() {
return port;
}
/**
* Close the socket if this hasn't already happened.
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
super.finalize();
socket.close();
}
/**
* Close the socket and free-up resources.
* It is recommended that clients call this when they are done with the
* port.
*/
public void close() {
socket.close();
}
}