我正在尝试通过套接字发送一个字符串数组并在另一端接收它。
这是我的客户端(发送数据的一方):
char* client_hello[] =
{
"Type client_hello",
"Version SSLv3.0",
"Session ID 1",
"Random 1as2@3%$h&KF(*)JAGG&(@H%A$D@J*@@",
"Cipher-Suites TLS_RSA_WITH_RC4_128_SHA",
"Compression null(0)"
};
SendBytes = send(sock, client_hello, 6, 0);
这是我的服务器端(接收数据的端):
int inMsgLen = recvfrom(clntSock, inMsg, 1024, 0,(struct sockaddr *)&clntAddr, (socklen_t*)&clntAddrLen);
if (inMsgLen < 0) {
//printf("Error in recvfrom() errno=%d\n", errno);
continue;//exit(1);
}else if (inMsgLen > 1024) {
printf("Received message too long (size=%d)\n", inMsgLen);
exit(1);
}else{
printf("Received Message: %s\n", inMsg);
}
inMsg
被声明为char inMsg[1024];
这是服务器端的输出:
Received Message: +?
我究竟做错了什么 ?如何发送/接收整个 client_hello 数组?