C++ socket编程中,如果
其中一端是 write(fd, new char[10], 10).
而另一端是 read(fd, new int[5], 5)
请问return的数值是什么?-1? 5?
迷茫2017-04-17 15:26:04
Socket does not know your data type and treats it as a char sequence. If the types are inconsistent, it does not matter. Anyway, it only guarantees that the byte sequence is the same. It is equivalent to (int*)(new char[10]).
天蓬老师2017-04-17 15:26:04
In a non-good network environment (for example, LAN), the return value should be a random value.
Because they have no relationship in the first place. .