如何发送到服务器 4 个字节int
并在服务器端将此缓冲区转换为 int。
客户端:
void send_my_id()
{
int my_id = 1233;
char data_to_send[4];
// how to convert my_id to data_send?
send(sock, (const char*)data_to_send, 4, 0);
}
服务器端:
void receive_id()
{
int client_id;
char buffer[4];
recv(client_sock, buffer, 4, 0);
// how to conver buffer to client_id? it must be 1233;
}