0

I am new to C Network programming and I need to update the program to take port# as argument from the command line but I keep getting a segmentation fault error. Not sure how to fix. any help will be appreciated.

Here is the Server program code where the port number is hard coded

serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(5000);

This is the Client program code

serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(5000);

How to do I change it to start receiving port # as input from cmdline

SBHK
  • 1

0 Answers0