Operating System: Title
Operating System: Title
OPERATING SYSTEM
PROJECT COMPONENT
GROUP MEMBERS:
SAI PRATHAP REDDY :18BCE0111
C.GOWTHAM :18BCE0099
T.ADITYA REDDY :18BCE0045
E.PHANEENDRA :18BEC0061
CONTENTS:
1. ABSTRACT
2. INTRODUCTION
3. TYPES OF NETWORK COMMUNICATION
4. RELATED WORKS
i. Many of the researchers proposed many methods
5.PROPOSED METHOD/ ALGORITHM
6.RESULT AND DISCUSSION
7.SERVER CODE
8.CLIENT CODE
9.CONCLUSION
i. Current applications of client server mode.
ii. The future of client/server system.
10.REFERENCES
1.ABSTRACT:
Fig 2.1
ii. Client
A client is a requesting program or user in a client-server relationship.
Fig 2.2
iii. Server
The computer handling the request and sending back the HTML file is a
server.
iv. Socket
• TCP/IP
• While OSI is more of a theoretical model, the TCP/IP networking model
is the most popular and widely used.
• the communication over the network in TCP/IP model takes place in
form of a client server architecture
• client begins the communication and server follows up and a connection
is established.
• The Transmission Control Protocol (TCP) is one of the main protocols of
the Internet protocol suite.
• It originated in the initial network implementation in which it
complemented the Internet Protocol (IP). Therefore, the entire suite is
commonly referred to as TCP/IP
4.RELATED WORKS:
5.PROPOSED METHOD/ALGORITHM
I. CLIENT:
DEFINITION:
struct sockaddr_in
{ short sin_family; u_short sin_port;
struct in_addr sin_addr; char
sin_zero[8]
};
1. serv_addr will contain the address of the server.
2. socklen_t is an intr type of width of at least 32 bits.
The accept() system call causes the process to block until a client connects to the
server. Thus, it wakes up the process when a connection from a client has been
successfully established.
It returns a new file descriptor, and all communication on this connection should
be done using the new file descriptor.
The second argument is a reference pointer to the address of the client on the
other end of the connection, and the third argument is the size of this structure.
*/
/*
II. SERVER:
returns -1.
*/
/*
The variable serv_addr is a structure of
sockaddr_in. sin_family contains a
code for the address family.
It should always be set to AF_INET.
htons() converts the port number from
host byte order to a port number in
network byte order.
*/
The fork() system call will be used to create multiple clients that will interact with
the server.
It returns a unique pid value for each clients or child process or request thus
helps in connecting to server individually.
/* ---------------- CLOSE CALL -------------- */
/* ----------------- close() ---------------- */*
Once the server presses # to end the
connection, the loop will break and it
will close the server socket connection
and the client connection
6.RESULT AND DISCUSSION
From the above project, a multithreaded client server system is successfully
established. With the use of operating system concepts like creating processes using fork()
and a little of networking concepts like socket programming is shown that when different
clients are requesting the server for interaction, the server create many child processes which
handles the request of different clients accessing the server. Thus, a system is created in which
clients and servers are connected to a common network.
Fig 6.1
7.SERVER CODE:
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(){
int sockfd, ret;
struct sockaddr_in serverAddr;
int newSocket;
struct sockaddr_in newAddr;
socklen_t addr_size;
char buffer[1024];
pid_t childpid;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd < 0){
printf("[-]Error in connection.\n");
exit(1);
}
printf("[+]Server Socket is created.\n");
memset(&serverAddr, '\0', sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(PORT);
serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
close(newSocket);
return 0;
}
SERVER OUTPUT:
Fig 7.1
8.CLIENT CODE:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
while(1){
printf("Client: \t");
scanf("%s", &bufer[0]);
return 0;
}
CLIENT 1:
Fig 8.1
CLIENT 2:
Fig 8.2
CLIENT 3 :
Fig 8.3
9. CONCLUSION
Client/server program for concurrent server using fork and thread is implemented
and show along with the execution. Synchronization problem exist with threads
which can be overcome by using mutex and condition variables. The advantage of
implementing this methods are the central management of server. Also this is
good for server administrator because they only have to be in one place and can
solve all the problems in one place as well. The configuration is simple to setup.
Moreover it takes less time to troubleshoot because troubleshooting takes place at
one physical server. The major problems that occurs due to this server client
model is that all the resources are located on one server , this creates a single
point of failure. It means that if anything should happen to the server such as a
crashed hard drive that is not recoverable, then all the resources that were once
hosted on that server will no longer be available.
(i) CURRENT APPLICATIONS OF CLIENT SERVER MODEL
The future will provide information from data in its original form: image, video,
audio, graphics, document, spreadsheet, or structured data, without the need to be
aware of specific software for each form. Successful organizations of the future—
those that are market-driven and competitive—will be ones using client/server as
an enabling technology to add recognized value to their product or service.
10.References: