0

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?

CustomCase
  • 247
  • 1
  • 4
  • 15

2 Answers2

1

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.

cmasupra
  • 328
  • 4
  • 11
0

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.

Mark Leighton Fisher
  • 5,609
  • 2
  • 18
  • 29