简体   繁体   中英

Java Sockets: Socket.close() terminates connection different on Windows and Mac?

Situation is as follows: I have a Java Application, that communicates over TCP to a Microcontroller with TCP Stack on it. The Stack on the Controller works fine, I can sort this out.

Problem is: When I terminate my connection to the Controller, I simply use socket.close() and the connection is terminated, no problem. On my Mac, this works too, but when I check Wireshark, there is the regular termination process [FIN,ACK] - [ACK] , but followed by a [TCP Dup ACK] Packet, that, so claimed by Wireshark, belongs to my [FIN,ACK] Packet. This only happens on a Mac and does not happen on a Windows machine on a VM on my mac or on my netbook...

Are there any tweaks I could use to not letting this Dup-ACK Packet to be transmitted? It actually jerks up the stack in the Controller by claiming that the closed session is still active and after 10 times connecting to the controller, the stack has no more space to accept new connections.

I'd be really thankful if someone could give me a hint!

Well, if this is a problem in OS-provided TCP stack (which I believe it is) you may try to telnet from your mac to the device and close the connection. Just to see whether this dup ack would be still emitted. If it is, than swapping java versions/vendors (for example) won't do much good...

...oh, and maybe you'd be able to filter the offending packet with your firewall? That's a wild guess, as I actually know nothing about firewalling for MacOS...

I would actually recommend talking to the vendor of your MCU's tcp/ip stack.

While you might be able to tweak this one particular mac, you're going to have to get this fixed more permanently. And there's enough macs out there that you're going to have to deal with it sooner or latter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM