Here is a simple socket. No matter in which file if statement is declared,
int main()
{
int sock, bytes_recieved;//, number;
char send_data[1024],recv_data[1024];
host = gethostbyname("127.0.0.1");
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(1237);
while(1)
{
bytes_recieved = recv(sock,recv_data,1024,0);
recv_data[bytes_recieved] = '\0';
if (recv_data[0] == "q" || recv_data[0] == "Q")
{
printf("Why do you want to close socket dude?\n");
close(sock);
break;
}
}
close(sock);
return 0;
}
after running both in client and server are coming with the error below in teminal
client.c:49:26: warning: comparison between pointer and integer if (recv_data[0] == "q" || recv_data[0] == "Q") ^
Aucun commentaire:
Enregistrer un commentaire