Files
BlueSocket/Sources
Jim Dovey c8ee463a06 Makes sure that the temporary socket opened in Socket.connect(to:port:timeout:) is closed in the event of an error being thrown.
I've added two pieces here: first is a `defer` block right after the creation of the `socketDescriptor` variable. If it's non-nil and not `Socket.SOCKET_INVALID_DESCRIPTOR` then the socket is closed pronto. Secondly, I'm explicitly setting this variable to `nil` when it's copied into `self.socketfd`. From that point on, any failure or error thrown will not result in the socket being orphaned, since it's referenced by the `Socket` class instance, and will be cleaned up in its `deinit` implementation.
2018-02-22 13:08:31 -08:00
..