You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes I need to write integration tests where I basically just need a connected socket (without doing anything to it). But somewhat later I want to hand this file descriptor into a library which then does networking with the already-open socket.
The only way I can achieve this today is:
Use socket+connect to get a raw socket
... do test setup ...
Use library (or ClientBootstrap.withConnectedSocket(...)) to then kick off the actual processing
It's annoying that I can't currently use SwiftNIO to perform step 1. I mean I can easily create a socket and not do anything with it, but I can't get the file descriptor of the underlying socket. What I'd love to do is something like
let channel = try ClientBootstrap(...)
.connect(host: ..., port: ...)
.wait()
let fileDescriptorPromise = channel.eventLoop.makePromise(of: CInt.self)
try channel.triggerOutboundUserEvent(SpecialCloseChannelAndGiveMeTheSocketFD(fileDescriptorPromise)).wait()
let fd = try fileDescriptorPromise.futureResult.wait()
[...]
let channelAgain = try ClientBootstrap(...)
.channelInitializer { channel in
// actual setup
}
.withConnectedSocket(fd)
.wait()
The semantic I would want is: Do everything exactly like a close(mode: .all), except when NIO would normally call close(fd), don't do that and provide me with the (now unmanaged by NIO) fd.
The text was updated successfully, but these errors were encountered:
Sometimes I need to write integration tests where I basically just need a connected socket (without doing anything to it). But somewhat later I want to hand this file descriptor into a library which then does networking with the already-open socket.
The only way I can achieve this today is:
socket
+connect
to get a raw socketClientBootstrap.withConnectedSocket(...)
) to then kick off the actual processingIt's annoying that I can't currently use SwiftNIO to perform step 1. I mean I can easily create a socket and not do anything with it, but I can't get the file descriptor of the underlying socket. What I'd love to do is something like
The semantic I would want is: Do everything exactly like a
close(mode: .all)
, except when NIO would normally callclose(fd)
, don't do that and provide me with the (now unmanaged by NIO) fd.The text was updated successfully, but these errors were encountered: