File tree Expand file tree Collapse file tree
Sources/OSCKit/TCP/Server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ public final class OSCTCPServer {
4545 /// Network interface to restrict connections to.
4646 public let interface : String ?
4747
48+ /// Returns a boolean indicating whether the OSC server has been started.
49+ public private( set) var isStarted : Bool = false
50+
4851 /// Initialize with a remote hostname and UDP port.
4952 ///
5053 /// > Note:
@@ -94,10 +97,14 @@ extension OSCTCPServer: @unchecked Sendable { } // TODO: unchecked
9497extension OSCTCPServer {
9598 /// Starts listening for inbound connections.
9699 public func start( ) throws {
100+ guard !isStarted else { return }
101+
97102 try tcpSocket. accept (
98103 onInterface: interface,
99104 port: _localPort ?? 0 // 0 causes system to assign random open port
100105 )
106+
107+ isStarted = true
101108 }
102109
103110 /// Closes any open client connections and stops listening for inbound connection requests.
@@ -107,6 +114,8 @@ extension OSCTCPServer {
107114
108115 // close server
109116 tcpSocket. disconnectAfterWriting ( )
117+
118+ isStarted = false
110119 }
111120}
112121
You can’t perform that action at this time.
0 commit comments