C++通过套接字连接发送矢量
C++ sending a vector across a socket connection
我正在尝试通过套接字发送向量,但遇到一系列错误,我不确定如何解决。
矢量和通过套接字发送如下所示:
int code = 52;
std::vector<uint8_t> data1 = { 4, 1, 0, 0, 0, 0, static_cast<uint8_t>(224 + code / 16), static_cast<uint8_t>(code % 16) };
comm_send1 = send(sock, data1.data(), data1.length(), 0);
错误是:
Error (active) E0167 argument of type "uint8_t *" is incompatible with parameter of type "const char *"
Error (active) E0135 class "std::vector<uint8_t, std::allocator<uint8_t>>" has no member "length"
Error C2039 'length': is not a member of 'std::vector<uint8_t,std::allocator<_Ty>>'
Error C2660 'send': function does not take 3 arguments
谁能帮忙?
谢谢
send 函数除了 uint8_t* 之外,所以你应该像这样强制转换向量的内容:(const char*(data1.data((; 此外,向量类没有长度((方法,您应该使用size((
相关文章:
- 当套接字连接断开时检测C/C++Unix
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- 如何在 2 台主机之间保持 UDP 套接字连接打开
- Opencv 不适用于套接字连接
- C++通过套接字连接发送矢量
- mbed 套接字连接需要很长时间
- 重用多个请求的相同套接字连接
- C++ Linux 上的套接字连接
- 套接字连接在主功能内部但不在功能内部
- 套接字连接上的缓冲区溢出
- 套接字连接()被误认为是QT connect()
- 返回打开的插座连接/留下套接字连接打开C
- 当试图连接到无法到达的计算机时,C 套接字连接被卡住
- C# 客户端到C++服务器 Tcp 套接字连接错误
- C [UDP]如何跟踪服务器上的所有连接(客户端)套接字连接
- 使用C 安全套接字连接
- 在C 中每分钟之后,如何检查套接字连接
- 正在创建多个TCP套接字连接
- 为什么我不能通过套接字连接android和PC
- 如何在删除或处理文件夹树时处理符号链接和连接