Skip to content

Commit

Permalink
Revert "FlyingSocks: use send(to:) instead of write() for UDP"
Browse files Browse the repository at this point in the history
This reverts commit 71e02d0.
  • Loading branch information
lhoward committed Nov 28, 2024
1 parent 71e02d0 commit efd37cd
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions Sources/SwiftOCA/OCP.1/Backend/Ocp1FlyingSocksConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ public class Ocp1FlyingSocksConnection: Ocp1Connection {
}
}

override public func write(_ data: Data) async throws -> Int {
try await withMappedError { socket in
try await socket.write(data)
return data.count
}
}

var socketType: SocketType {
fatalError("socketType must be implemented by a concrete subclass of Ocp1FlyingSocksConnection")
}
Expand All @@ -188,13 +195,6 @@ public final class Ocp1FlyingSocksStreamConnection: Ocp1FlyingSocksConnection {
}
}

override public func write(_ data: Data) async throws -> Int {
try await withMappedError { socket in
try await socket.write(data)
return data.count
}
}

override func setSocketOptions(_ socket: Socket) throws {
if deviceAddress.family == AF_INET {
try socket.setValue(true, for: BoolSocketOption(name: TCP_NODELAY), level: CInt(IPPROTO_TCP))
Expand All @@ -220,13 +220,6 @@ public final class Ocp1FlyingSocksDatagramConnection: Ocp1FlyingSocksConnection
try await Data(socket.read(atMost: Ocp1MaximumDatagramPduSize))
}
}

override public func write(_ data: Data) async throws -> Int {
try await withMappedError { socket in
try await socket.send(data, to: deviceAddress)
return data.count
}
}
}

func deviceAddressToString(_ deviceAddress: any SocketAddress) -> String {
Expand Down

0 comments on commit efd37cd

Please sign in to comment.