vapor-community / sockets

🔌 Non-blocking TCP socket layer, with event-driven server and client.
MIT License
575 stars 54 forks source link

adding close capabilities #38

Closed loganwright closed 8 years ago

czechboy0 commented 8 years ago

Fixes #35, @tannernelson are there any more cases when the isClosed property should be changed? Thanks @LoganWright!

tanner0101 commented 8 years ago

I think we should use closed: Bool so that it conforms to C7.Stream more easily.

tanner0101 commented 8 years ago

In Hummingbird, looks like closed is only set to true when close() is called.

"closed by peer" errors are thrown on send and handled differently.


Searching 18 files for "closed = "

/Users/tanner/Downloads/Hummingbird-master/Sources/ServerSocket.swift:
   52          guard setsockopt(socketDescriptor, SOL_SOCKET, SO_REUSEADDR, &optval, socklen_t(sizeof(Int))) != -1 else {
   53              let _ = systemClose(socketDescriptor)
   54:             closed = true
   55              #if swift(>=3.0)
   56                  let message = String(validatingUTF8: strerror(errno))

/Users/tanner/Downloads/Hummingbird-master/Sources/Socket.swift:
   20  
   21      /// `true` if the socket is closed. Otherwise `false`.
   22:     public internal(set) var closed = false
   23  
   24      /** 
   ..
  201              throw SocketError.closeFailed(code: Int(errno), message: message)
  202          }
  203:         closed = true
  204      }
  205  

3 matches across 2 files
czechboy0 commented 8 years ago

@LoganWright Do you want to rename it?

loganwright commented 8 years ago

@czechboy0 renamed, the conflict I was originally avoiding is no longer an issue since it's not in protocol

tanner0101 commented 8 years ago

This looks good to me

czechboy0 commented 8 years ago

Cool, thanks guys!