网络编程 - C++ socket编程中,read/write 参数类型不同会怎样?
巴扎黑
巴扎黑 2017-04-17 15:24:04
0
2
657

C++ socket编程中,如果

其中一端是 write(fd, new char[10], 10).
而另一端是 read(fd, new int[5], 5)
请问return的数值是什么?-1? 5?

巴扎黑
巴扎黑

reply all(2)
迷茫

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]).

Peter_Zhu

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. .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!