Method: OpenC3.close_socket
- Defined in:
- lib/openc3/top_level.rb
.close_socket(socket) ⇒ Object
Close a socket in a manner that ensures that any reads blocked in select will unblock across platforms
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'lib/openc3/top_level.rb', line 538 def self.close_socket(socket) if socket # Calling shutdown and then sleep seems to be required # to get select to reliably unblock on linux begin socket.shutdown(:RDWR) sleep(0) rescue Exception # Oh well we tried end begin socket.close unless socket.closed? rescue Exception # Oh well we tried end end end |