简体   繁体   English

Java:另一端通过套接字的DataOutputStream错误(Python)

[英]Java: DataOutputStream through socket is wrong on other side (which is Python)

I've got a Socket , s and an long , 1312992 . 我有一个Socketslong1312992

DataOutputStream out = new DataOutputStream(s.getOutputStream());
out.writeLong(hwnd);
out.flush();

Doing 在做

self.hwnd, = struct.unpack('!Q', self.appletconn.recv(8))
print(self.hwnd)

on the (python) receiving side prints out 51 . 在(python)接收端打印51 I presume something's wrong with my sending code. 我认为我的发送代码有问题。

Thanks. 谢谢。

Use a packet capture tool like tcpdump or wireshark and check what is going on the wire. 使用数据包捕获工具(如tcpdump或Wireshark),检查线路上的状况。 I am guessing, you might be mixing text and binary on sending and/or receiving side. 我猜,您可能在发送和/或接收端混合了文本和二进制文件。

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

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