Search code examples
csocketsclient-servertcpclient

TCP Concurrent Client/Server in C by using Fork()


asdfg askjhgkasdhj gfskjd;hdgfk ;jasgdjkf hasdjkghf asdjkf hasdjkfgh klasdhdf jkasdjkf hdjksahf jklhdjkf asjkdhdf jkdlf ajsdhf jklashdf jaksdf hkjlasdjklf hasdhdf kdf kjlasdhdf hkjadf ljkdf adf kjahdkf adf kjashdfhkjlsasdf

 else {
        printf("[-]Invalid command\n");
      }
    }

    bzero(buffer, SIZE);
  }

}

Solution

  • You have a couple of issues:

    -Don't close sockfd, this will prevent further connections from being accepted on the server
    -The socket should be closed on both ends in the quit case
    -The fact that the client side uses a random port is fine.  Nothing needs to be changed there