That leaves the 0's from the address buffer in the String. I think you probably want some
return String(cString: addressBytesPtr)
variant here, so that the string terminates at the \0.
Other potential causes: incorrect indentation, 80-column source line length overflows all over.
SwiftNIO version/commit hash
1.1
Swift & OS version (output of swift --version && uname -a)
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9
Darwin ZeaPro.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64
Expected behavior
No 0 bytes in strings
Actual behavior
0 bytes in strings
Steps to reproduce
In Xcode:
print("Server running on:", serverChannel.localAddress!)
It says:
Server running on: [IPv6]::1<NUL><NUL><NUL>....lots...
Some editors seem to eat the \0's.
Cause
I think it is
That leaves the
0's
from the address buffer in the String. I think you probably want somereturn String(cString: addressBytesPtr)
variant here, so that the string terminates at the
\0
.Other potential causes: incorrect indentation, 80-column source line length overflows all over.
SwiftNIO version/commit hash
1.1
Swift & OS version (output of
swift --version && uname -a
)Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2) Target: x86_64-apple-macosx10.9 Darwin ZeaPro.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64