Professional Documents
Culture Documents
Client Server in C
Client Server in C
Report on
S
u
Submitted By
VAIBHAW RAI
2017PGCACA03
1
S.NO. TITLES PAGE NO.
1 Certificate 3
2 Title 4
3 Introduction 5
4 System Analysis 5
5 Objective 6
5 Technology Used 6
6 Project Planning 7
7 Requirements 8
8 Modules 8
9 Working Process Diagram 9
10 Security Mechanism 9
11 Coding 11-15
12 Output 16
13 Future Scope 17
14 Bibliography 17
2
CERTIFICATE
3
4
INTRODUCTION
Purpose:-
SYSTEM ANALYSIS
The goals and purpose for creating this software to make a text
chatting system over any particular port. Port numbers 0 to 1024
are reserved for privileged services and designated as well-
known ports. This list of port numbers are specified in RFC 1700.
In TCP/IP and UDP networks. So, we may able to chat over ports
which is not reserved i.e. greater than 1024. The ports near 4000 are
reliable for a TCP connection which easily provide us to send the text
messages from server to client and vice versa.
5
OBJECTIVES
The objective of this software is to do the text
communication from two different places with the help of
server.
TECHNOLOGY USED
Hardware
Software
Front End:- C Programming
O.S. :- LINUX
6
PROJECT PLANNING
This is the measure part of a software development life cycle.
In this we must consider various points regarding our
projects, and follows the instructions step by step for
developing the software.
7
REQUIREMENTS
o TCP/IP Network
A TCP/IP network connection is required to send
and receive the information over any defined port
On the TCP network.
o Internet Connection
Internet connection is required to perform the
chatting operation, firstly it may be tested while
creating the local host to the computer.
MODULES
Client:-
The client is a user which send a text message to
the server, if the server is active.
Server:-
It takes port as input and provide a path to the
client to communicate with it over the port.
8
THE WORKING PROCESS DIAGRAM
Administrator
Chatting Security
9
The feasibility study investigates the problem and the information
needs of the stakeholders. It seeks to determine the resources
required to provide an information systems solution, the cost and
benefits of such a solution, and the feasibility of such a solution. The
analyst conducting the study gathers information using a variety of
methods, the most popular of which are:
Developing and administering questionnaires to interested stakeholders,
such as potential users of the information system.
Modelling, observing, and simulating the work activities of the current
system.
1. Economic feasibility:
1. Technical Feasibility:
10
CODING
#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>
char buffer1[256],buffer2[256];
if(argc < 3)
{
fprintf(stderr,"Usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd=socket(AF_INET, SOCK_STREAM, 0);
11
if(sockfd<0)
{
error("Error Opening Socket");
}
server = gethostbyname(argv[1]);
if(server == NULL)
{
fprintf(stderr,"Error, no such host\n");
exit(0);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
n=write(sockfd,buffer1,strlen(buffer1));
if(n<0)
error("Error writing to socket");
bzero(buffer2,256);
n=read(sockfd,buffer2,255);
if(n<0)
error("Error reading from Socket");
printf("Server Reply : %s\n",buffer2);
n=strcmp(buffer1,str);
a=strcmp(buffer2,str);
12
if(n==-1)
n=0;
}
while(a!=0 || n!=0);
close(sockfd);
return 0;
}
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<string.h>
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
bzero(buffer1,256);
n=read(newsockfd,buffer1,255);
if(n<0)
error("Error reading from socket");
do
{
printf("Client Message : %s\n",buffer1);
printf("Reply : ");
bzero(buffer2,256);
gets(buffer2);
n=write(newsockfd,buffer2,255);
if(n<0)
error("Error reading from socket");
bzero(buffer1,256);
n=read(newsockfd,buffer1,255);
if(n<0)
error("Error reading from socket");
14
n=strcmp(buffer1,str);
a= strcmp(buffer2,str);
if(n==-1)
n=0;
}
while(a!=0 || n!=0);
close(newsockfd);
close(sockfd);
return 0;
}
15
OUTPUT
Starting Server
Sending Message
16
FUTURE SCOPE
BIBLIOGRAPHY
Books :
Practical guide to socket programming in C.
Websites :
www. lokiastari.com
17