Skip to content

Commit

Permalink
Avoid closing sockets twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Goos committed Jan 27, 2023
1 parent 845ada7 commit a77d29a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/TCPSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ public final class TCPSocket {

/// Close the socket
func close() {
guard fileDescriptor != -1 else {
return
}
_ = SystemLibrary.shutdown(fileDescriptor, Int32(SHUT_WR))
_ = SystemLibrary.close(fileDescriptor)
fileDescriptor = -1
}

func getPeerName() throws -> (String, Int) {
Expand Down

0 comments on commit a77d29a

Please sign in to comment.