Skip to content

Commit b366f5e

Browse files
ignatovSAjulien-c
authored andcommitted
Fixed pointer operations in Socket (Xcode10 compilation) (#318)
* Fixed pointer operations in Socket. * Fixed pointer operations in Socket for Linux.
1 parent b332956 commit b366f5e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/Socket.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ open class Socket: Hashable, Equatable {
5353
if getsockname(socketFileDescriptor, UnsafeMutablePointer(OpaquePointer(pointer)), &len) != 0 {
5454
throw SocketError.getSockNameFailed(Errno.description())
5555
}
56+
let sin_port = pointer.pointee.sin_port
5657
#if os(Linux)
57-
return ntohs(addr.sin_port)
58+
return ntohs(sin_port)
5859
#else
59-
return Int(OSHostByteOrder()) != OSLittleEndian ? addr.sin_port.littleEndian : addr.sin_port.bigEndian
60+
return Int(OSHostByteOrder()) != OSLittleEndian ? sin_port.littleEndian : sin_port.bigEndian
6061
#endif
6162
}
6263
}
@@ -68,7 +69,7 @@ open class Socket: Hashable, Equatable {
6869
if getsockname(socketFileDescriptor, UnsafeMutablePointer(OpaquePointer(pointer)), &len) != 0 {
6970
throw SocketError.getSockNameFailed(Errno.description())
7071
}
71-
return Int32(addr.sin_family) == AF_INET
72+
return Int32(pointer.pointee.sin_family) == AF_INET
7273
}
7374
}
7475

0 commit comments

Comments
 (0)