I have a server and a client program that talks to eachother over a socket connection. It sends strings of data that I monitor via telnet / (or terminal? on mac).

It works fine, when I use my MAC as a server and my PC as a client. It does not work when I use my MAC as a client, and PC as a server... (!?)

Could it be that it the interperets "\n\r" (EOL?) differently since there are two different OS?

Does anybody have a clue / tip / workaround on how to solve this easy?

有帮助吗?

解决方案

Windows actually uses \r\n as EOL. It shouldn't behave differently on different OSes, though. Mac uses \r, so it ignores \n, and vice versa for *nix. Windows ignores both \r and \n unless they're next to each other in the order \r\n.

When programming with EOL, most languages only use \n and auto-convert the format when necessary.

其他提示

If I recall correctly, Macs use CR ("\r") as their single end-of-line character. Since Windows uses "\r\n" (CR-LF) for end-of-line, you may need to compensate for that in your code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top