简体   繁体   English

Java套接字:Socket.close()在Windows和Mac上终止不同的连接?

[英]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. 情况如下:我有一个Java应用程序,它通过TCP与具有TCP堆栈的微控制器通信。 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. 问题是:当我终止与Controller的连接时,我只是使用socket.close()并且连接终止,没问题。 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. 在我的Mac上,这也有效,但是当我检查Wireshark时,有常规终止进程[FIN,ACK] - [ACK] ,但后面跟着一个[TCP Dup ACK]数据包,由Wireshark声称属于我的[FIN,ACK]数据包。 This only happens on a Mac and does not happen on a Windows machine on a VM on my mac or on my netbook... 这只发生在Mac上,并且不会发生在我的Mac或我的上网本上的VM上的Windows机器上...

Are there any tweaks I could use to not letting this Dup-ACK Packet to be transmitted? 我是否可以使用任何调整来不让这个Dup-ACK数据包被传输? 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. 它实际上通过声称关闭的会话仍然处于活动状态并且在连接到控制器10次后,堆栈中没有更多空间来接受新连接,从而使控制器中的堆栈猛然抬起。

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. 好吧,如果这是OS提供的TCP堆栈中的问题(我相信它是),您可以尝试从mac telnet到设备并关闭连接。 Just to see whether this dup ack would be still emitted. 只是为了看看是否仍然会发出这个重复的ack。 If it is, than swapping java versions/vendors (for example) won't do much good... 如果是,比交换java版本/供应商(例如)不会做太多好事......

...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... 这是一个疯狂的猜测,因为我实际上对MacOS的防火墙一无所知......

I would actually recommend talking to the vendor of your MCU's tcp/ip stack. 我实际上建议您与MCU的tcp / ip堆栈的供应商交谈。

While you might be able to tweak this one particular mac, you're going to have to get this fixed more permanently. 虽然您可能能够调整这个特定的mac,但您必须更加永久地修复此问题。 And there's enough macs out there that you're going to have to deal with it sooner or latter. 那里有足够的mac,你将不得不早晚处理它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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