Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int newfd;
- sin_size = sizeof( my_addr );
- while(1)
- {
- struct sockaddr_in their_addr;
- bzero( & their_addr, sizeof( their_addr ) );
- if((newfd= accept(sockfd,( struct sockaddr *) &their_addr, &sin_size))==-1)
- {
- printf( "Error - accept\n" ); //wylaczona notyfikacja, poniewaz polaczenia nie sa blokujace i bylby niezly span na ekranie
- continue;
- }
- printf("And we have a client from: %s\n",inet_ntoa(their_addr.sin_addr));
- sleep(5);
- if(send(sockfd,"witaj kliencie\n",15,0)==-1)
- {
- printf("Error - send\n");
- }
- else
- printf("podobno wyslano\n");
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- while( recv(sockfd,buf,sizeof(buf),0)> 1 )
- {
- printf("serwer mowi:\"%s\"\n",buf);
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement