Ver código fonte

Merge branch 'patch-2' of git://github.com/Hanul/swifter into Hanul-patch-2

# Conflicts:
#	Sources/Swifter/Socket.swift
Damian Kołakowski 10 anos atrás
pai
commit
bbc183196e
1 arquivos alterados com 6 adições e 2 exclusões
  1. 6 2
      Sources/Swifter/Socket.swift

+ 6 - 2
Sources/Swifter/Socket.swift

@@ -119,7 +119,11 @@ public class Socket : Hashable, Equatable {
         try data.withUnsafeBufferPointer { pointer in
             var sent = 0
             while sent < data.count {
-                let s = write(self.socketFileDescriptor, pointer.baseAddress + sent, Int(data.count - sent))
+                #if os(Linux)
+                    let s = send(self.socketFileDescriptor, pointer.baseAddress + sent, Int(data.count - sent), Int32(MSG_NOSIGNAL))
+                #else
+                    let s = write(self.socketFileDescriptor, pointer.baseAddress + sent, Int(data.count - sent))
+                #endif
                 if s <= 0 {
                     throw SocketError.WriteFailed(Socket.descriptionOfLastError())
                 }
@@ -210,4 +214,4 @@ public class Socket : Hashable, Equatable {
 
 public func ==(socket1: Socket, socket2: Socket) -> Bool {
     return socket1.socketFileDescriptor == socket2.socketFileDescriptor
-}
+}