Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions FlyingSocks/Sources/AsyncSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public struct AsyncSocket: Sendable {
message: [UInt8],
to peerAddress: some SocketAddress,
interfaceIndex: UInt32? = nil,
from localAddress: (some SocketAddress)? = nil
from localAddress: (any SocketAddress)? = nil
) async throws {
let sent = try await pool.loopUntilReady(for: .write, on: socket) {
try socket.send(message: message, to: peerAddress, interfaceIndex: interfaceIndex, from: localAddress)
Expand All @@ -251,19 +251,11 @@ public struct AsyncSocket: Sendable {
}

public func send(message: Message) async throws {
let localAddress: AnySocketAddress?

if let unwrappedLocalAddress = message.localAddress {
localAddress = AnySocketAddress(unwrappedLocalAddress)
} else {
localAddress = nil
}

try await send(
message: message.bytes,
to: AnySocketAddress(message.peerAddress),
interfaceIndex: message.interfaceIndex,
from: localAddress
from: message.localAddress
)
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions FlyingSocks/Sources/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public struct Socket: Sendable, Hashable {
message: [UInt8],
to peerAddress: some SocketAddress,
interfaceIndex: UInt32? = nil,
from localAddress: (some SocketAddress)? = nil
from localAddress: (any SocketAddress)? = nil
) throws -> Int {
try message.withUnsafeBytes { buffer in
try send(
Expand All @@ -417,7 +417,7 @@ public struct Socket: Sendable, Hashable {
flags: Int32,
to peerAddress: some SocketAddress,
interfaceIndex: UInt32? = nil,
from localAddress: (some SocketAddress)? = nil
from localAddress: (any SocketAddress)? = nil
) throws -> Int {
var iov = iovec()
var msg = msghdr()
Expand Down Expand Up @@ -685,7 +685,7 @@ fileprivate extension Socket {
static func withPacketInfoControl<T>(
family: sa_family_t,
interfaceIndex: UInt32?,
address: (some SocketAddress)?,
address: (any SocketAddress)?,
_ body: (UnsafePointer<cmsghdr>?, ControlMessageHeaderLengthType) -> T
) -> T {
switch Int32(family) {
Expand Down
Loading