简体   繁体   中英

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

I've got a Socket , s and an long , 1312992 .

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 . 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. I am guessing, you might be mixing text and binary on sending and/or receiving side.

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