Respect link MTU in TCP

Mitigates #39
This commit is contained in:
Davide De Rosa 2018-10-21 14:07:37 +02:00
parent 26fc12c2ef
commit f93634bd7a

View File

@ -106,7 +106,7 @@ class NETCPSocket: NSObject, GenericSocket {
}
func link(withMTU mtu: Int) -> LinkInterface {
return NETCPLink(impl: impl)
return NETCPLink(impl: impl, mtu: mtu)
}
// MARK: Connection KVO (any queue)
@ -181,9 +181,9 @@ class NETCPLink: LinkInterface {
private let maxPacketSize: Int
init(impl: NWTCPConnection, maxPacketSize: Int? = nil) {
init(impl: NWTCPConnection, mtu: Int, maxPacketSize: Int? = nil) {
self.impl = impl
self.mtu = .max
self.mtu = mtu
self.maxPacketSize = maxPacketSize ?? (512 * 1024)
}