1
0

IO.swift 654 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // OS.swift
  3. // Swifter
  4. //
  5. // Copyright © 2016 Damian Kołakowski. All rights reserved.
  6. //
  7. import Foundation
  8. public protocol IO: class {
  9. init(_ port: in_port_t, forceIPv4: Bool, bindAddress: String?) throws
  10. func wait(_ callback: ((IOEvent) -> Void)) throws
  11. func write(_ socket: Int32, _ data: Array<UInt8>, _ done: @escaping ((Void) -> IODoneAction)) throws
  12. func finish(_ socket: Int32)
  13. }
  14. public enum IODoneAction {
  15. case `continue`, terminate
  16. }
  17. public enum IOEvent {
  18. case connect(String, Int32)
  19. case disconnect(String, Int32)
  20. case data(String, Int32, ArraySlice<UInt8>)
  21. }