Hello.
Please help me figure out the next problem. In the server with c ++ I call the accept function to create a connection.
int sock = accept(sd, NULL, NULL);
And then I try to display the value of sock, but the screen is empty. It feels like the server just doesn't go out of acccept.
What can it be connected with?
struct sockaddr_in local; local.sin_family = AF_INET; local.sin_port = htons(1024); local.sin_addr.s_addr = htonl(INADDR_ANY); int sd; if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); } if(bind(sd,(struct sockaddr*)&local,sizeof(local))<0) { perror("bind"); exit(2); } listen(sd, 5); pthread_t tid; int newS; while(1) { newS = accept(sd, NULL, NULL); printf("%d", newS); } close(sd);