-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error code: -9993(0x-2709), Invalid argument #208
Comments
I think the "Socket.create" line may not be needed in your |
🤔 indeed must copied here by mistake. as a workaround I opt out to nc let pipe = Pipe()
let echo = Process()
echo.launchPath = "/usr/bin/env"
echo.arguments = ["echo"] + args.components(separatedBy: " ")
echo.standardOutput = pipe
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = ["nc", "-U", socketPath]
task.standardInput = pipe
echo.launch()
task.launch()
task.waitUntilExit()
if task.terminationStatus != 0 {
throw Error.processFailed(args)
} My attach function is now func attach() async {
do {
let socket = try Socket.create(family: .unix, type: .stream, proto: .unix)
try socket.listen(on: socketPath)
log.info("Listening on \(socketPath)")
while true {
let conn = try socket.acceptClientConnection()
let msg = try conn.readString()?.trimmingCharacters(in: .whitespacesAndNewlines)
conn.close()
await processMessage(msg)
if stop || restart {
log.info("No longer accepting connection to \(socketPath)")
break
}
}
} catch {
log.error("Socket error: \(error)")
}
if restart {
restart = false
await attach()
}
} |
I had same error but in different context. do {
let socket = try Socket.create(family: .inet, type: .datagram, proto: .udp)
let destination = Socket.createAddress(for: "localhost", on: 50000)
_ = try socket.write(from: Data("Message".utf8), to: destination!)
print("Sent message to 50000")
} catch {
print("Failed to send message to 50000 - \(error)")
} It worked few days ago, but now its not and that makes me crazy... the problem in |
If you're on macOS, I think localhost is defined for both ipv4 and ipv6, which I think can sometimes cause confusion. Is it more reliable if you use 127.0.0.1? Also how is your listening side declared? |
@dannys42 yes, im on macOS. no listener in this example. it just works w/o error if I change to |
|
I'm having an odd issue that I can't seem to be able to solve.
In my program I have a main unix socket that accept message and within the same program I have cli that create a socket and write to the main socket. The connection to main has no issues, it's when I write, the main socket error out with
Error code: -9993(0x-2709), Invalid argument
Main Socket:
CLI socket write:
The text was updated successfully, but these errors were encountered: