Question: The code needs to be in C. i have partial code for server class which is written below, please help with the rest(remaining server and
The code needs to be in C.
i have partial code for server class which is written below, please help with the rest(remaining server and client class) and also make all the necessary changes required in the given code:
#include #include #include #include #include #include #include #include
void error(const char *msg) { perror(msg); exit(1); }
void *threadFunction(int mysockfd) { char bufferThread[256]; int nThread; while(1) { bzero(bufferThread,256); nThread = read(mysockfd,bufferThread,255); //read message from mysockfd if (nThread
int main(int argc, char *argv[]) { int sockfd, newsockfd, portno; socklen_t clilen; char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n;
if (argc
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd
bzero((char *) &serv_addr, sizeof(serv_addr)); portno = atoi(argv[1]); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno);
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))
listen(sockfd,5);
clilen = sizeof(cli_addr); newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd
Also in the class this is how our professor wants us tocreate socket and bind it:
Create a socket with the socket() system call
Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine.
Listen for connections with the listen() system call. This call typically blocks until a client connects with the server.
Accept a connection with the accept() system call.
Send and receive data



Goal: To improve the client-server model introduced in the class Requirements: The server should be able to accept requests from multiple clients and communicate with them. .Each client should be able to communicate multiple rounds of messages with the server. .Whenever the server receives a message from a client, it replies with "I got your message To implement the server with multithreading. .A client program should terminate its communication with the server when its user types in "EXIT", causing no effect on other clients You can manually terminate the server using Ctrl C or you can implement it to terminate itself on a certain input from keyboard .The server and client should take arguments in the following formats server.exe [port number] client.exe [server's name] [port number] Your programs will be tested and graded using computers in Lab QBB 244 under the LINUX/UNIX mode. To submit .Source codes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
