Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

A

Report on

S
u
Submitted By
VAIBHAW RAI
2017PGCACA03

Under The Supervision of


Dr. Chandrashekhar Azad

DEPARTMENT OF COMPUTER APPLICATIONS


NIT JAMSHEDPUR – 831014
2017

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

This is to certify that this Project on Client Server Chatting System


embodies the original work done by Vaibhaw Rai during this project
submission as a partial fulfilment of the requirement for the System
Design Project of Masters of Computer Application I Semester, of the
National Institute of Technology, Jamshedpur.

Dr. Chandrashekhar Azad

3
4
INTRODUCTION
Purpose:-

The purpose of this application are as follows :


 The software is to provide the facility to user for chat over
the server from two different location.
 It is based on the text messaging system, i.e. user can
communicate while typing text messages.

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

Minimum Hard Drive Space: - 5 MB


Minimum Ram :- 2 MB

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.

There are following steps which comes under this.

 Analysis: An analysis is made towards this project to


what to do first i.e. what things are needed to prepare
the base of this software.

 Design: The design phase is not more considerable for


this project, because no any swing or graphical system is
used in this software, it is simple text based software.

 Coding: Coding is the most effective part of this


software. There are two phases one coding is for client
side coding and another is for server side coding.

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

CLIENT Communication SERVER


over entered TCP port

Administrator

An Administrator Id Password is to be provided to


start the server.

Chatting Security

The chatting is fully secured on the TCP network ports, so


no one can able to read the personal chat messages.

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.

The goal of the feasibility study is to consider alternative information


systems solutions, evaluate their feasibility, and propose the
alternative most suitable to the organization. The feasibility of a
proposed solution is evaluated in terms of its components. These
components are:

1. Economic feasibility:

The economic feasibility for this project is time, actually the


time factors and the project size factor calculates the cost of
the project. A project is approved only if it covers its cost in a
given period of time.

1. Technical Feasibility:

There is no external resources required or any such type of


hardware required to run this software. Only requirements
are given under the projects which is free of cost to run this
software.

10
CODING

Server Side Program

#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>

void error(char *msg)


{
perror(msg);
exit(0);
}
int main(int argc, char *argv[])
{
int sockfd,portno,n,a;
char str[]="BYE";
struct sockaddr_in serv_addr;
struct hostent *server;

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;

bcopy((char *)server->h_addr, (char


*)&serv_addr.sin_addr.s_addr,server->h_length);
serv_addr.sin_port = htons(portno);
if(connect(sockfd,&serv_addr,sizeof(serv_addr))<0)
error("Error Connecting");
do
{
printf("Message: ");
bzero(buffer1,256);
gets(buffer1);

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;
}

Client Side Program

#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<string.h>

void error(char *msg)


{
perror(msg);
exit(1);
}
int main(int argc, char *argv[])
{
int sockfd, newsockfd,portno, clilen;
char str[]="BYE";
char buffer1[256],buffer2[256];
struct sockaddr_in serv_addr,cli_addr;
int n,a;
if(argc<2)
{
fprintf(stderr,"Error,no port provided");
exit(1);
}
sockfd=socket(AF_INET, SOCK_STREAM,0);
if(sockfd<0)
13
error("Error Opening Socket");
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))<0)


error("ERROR on binding");
listen(sockfd,5);
clilen = sizeof(cli_addr);

newsockfd= accept(sockfd,(struct sockaddr *) &cli_addr, &clilen);


if(newsockfd < 0)
error("Error on Accept");

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

The server started over the port 4004.

 Connecting client to the server

After hitting enter the message reader is prompt to send


message to the server.

 Sending Message

 Exiting From Chat


Simply type BYE from both side. Then the chatting will
terminate.

16
FUTURE SCOPE

 We may use multiple user instead of the only 2 users.


 It is converted to a dynamic project in future.
 This concept is converted to the UDP socket programming
for the faster transferring of messages.
 We may use a database connectivity to create a backup of
chats over particular ports.

BIBLIOGRAPHY

Books :
 Practical guide to socket programming in C.
Websites :
 www. lokiastari.com

17

You might also like