Guest User

Untitled

a guest
Dec 16th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. int new_fd =0;
  2. new_fd = accept( server_fd, NULL, NULL );
  3. while( 1 ){
  4. // if I am doing read,write here I am able to accept multiple
  5. // requests from one client
  6. // I have also tried accept4() call mentioned inside man
  7. // tried with nc command too.
  8. }
  9.  
  10. while(1){
  11. int new_fd =0;
  12. new_fd = accept( server_fd, NULL, NULL );
  13. // if I am doing read write here I am able to accept
  14. // only one request with one client
  15. // I thought my client does not work properly
  16. // so I also tried with nc command
  17. // same goes with accept4()
  18. }
  19.  
  20. while(1){
  21. int new_fd =0;
  22. new_fd = accept( server_fd, NULL, NULL );
  23. if( fork() ==0 ){
  24. // if I am doing read, write here
  25. // I am able to accept one request from multiple clients
  26. // but one client is able to send only one request.
  27. // tried with accept4() and nc
  28. close( new_fd );
  29. }
  30.  
  31. int socket_fd;
  32. socket_fd = socket( AF_INET, SOCK_STREAM, 0);
  33.  
  34. // for socaddr_in.port port I have used htons()
  35. // for sockaddr_in.addr I have use inet_pton()
  36. connect(socket_fd(structsockaddr*)&socaddr_in,(socklen_t)
  37. sizeof(sockaddr_in));
  38.  
  39. while(1){
  40. // here where I am using read, write, fflush(), memset() call.
  41. }
Add Comment
Please, Sign In to add comment