[swift-server-dev] Draft proposal for TLS Service APIs(pleasereview)

Johannes Weiß johannesweiss at apple.com
Tue Mar 28 05:03:23 CDT 2017


Hi Helge and Gelareh,

> [...]
>> If you are talking about non-blocking by any chance, we have an implementation of this in BlueSSLService (https://github.com/IBM-Swift/BlueSSLService) which interfaces with a socket management layer (BlueSocket - https://github.com/IBM-Swift/BlueSocket).
> 
> Sounds good. Do you have an example demonstrating the use of BlueSocket in NIO mode? Like a simple client which just opens a socket connection to a TLS server and reads with NIO configured.

as far as I understand the source code BlueSocket is blocking IO only. But its API basically breaks the abstraction by giving you (publically!) direct access to the the file descriptor.



	///
	/// The file descriptor representing this socket. (Readonly)
	///
	public internal(set) var socketfd: Int32 = SOCKET_INVALID_DESCRIPTOR

(from: https://github.com/IBM-Swift/BlueSocket/blob/master/Sources/Socket.swift#L772 )

so what you could do is

fcntl(someBlueSocket.socketFD, O_NONBLOCK, 1)

and then put in in a kqueue/epoll/DispatchSource . I personally don't think that counts as non-blocking API but it's possible :)


> [...]

Cheers,
  Johannes


More information about the swift-server-dev mailing list