Question

When I'm sending, for example, "1234", the server, which is C++ using SFML library reads "1234╠╠╠╠╤lσ╝╝√=♦↑עσ". When sending from C++ SFML clinet to the server it's all OK. The original client written in Onj-c with Async Socket library. WTF? (All TCP)

Was it helpful?

Solution

It sounds like the server is assuming that the data it receives is null-terminated, but one of the clients is just sending "1234" instead of "1234\0". So the weird characters you're seeing might be whatever garbage happened to be in that part of the server's memory.

You can use a tool like Wireshark to see exactly what's going out over the wire, and how it differs between the two clients.

OTHER TIPS

I don't sure that this will help you, but I suggest to send something like this "1234\0".

A naive implementation in SFML does indeed assume a null-terminated field - and will show you its raw buffer. Which does indeed not terminate. Either terminate the sending string witha \0 or alternatively sent something like 12345 - and change the print to put a \0 at [len] - or similarly.

Get the string from your lib together with the lenght of the data and add \0 at [len]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top