서버에 보내는 방법 4 바이트 int
및 서버 측에서이 버퍼를 int로 변환하십시오.int를 보내고받는 C++
클라이언트 측 :
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;
}
수신에 대해서는 atoi, 송신에는 어떻게됩니까? – Almo
예 - 문자 보내기/받기도 가능합니다. – paulsm4