Sie sind auf Seite 1von 9

JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617

HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 18

The Guide of Implementing Chat Protocol: Study Case


on Using the Socket Programming Concept and Object
Oriented Programming
Hamdan O. Alanazi, Rafidah Md Noor 

Abstract: In the past, communication among people was limited and very difficult. Nowadays, the Internet makes our life very
easy. Through the Internet you can easily communicate with people in different corners of the world in a few seconds. These days,
the world has been converted into a small village by the Internet. The chat room is one of the effective communication tools. In this
paper, a new protocol is presented for the chat room using the socket programming concept. This protocol has been implemented
using Java.

Index Terms— Transmission Control Protocol, User Datagram Protocol, FTP and Chat Protocol.

——————————      —————————— 
operates at a higher level, concerned only with the
two end systems, for example, a Web browser and a
Web server. In particular, the TCP provides reliable,
1. INTRODUCTION ordered delivery of a stream of bytes from one
The term of chat room, or chatroom, is primarily program on one computer to another program on
used by the mass media to describe any form of another computer. Besides the Web, other common
synchronous conferencing, occasionally even applications of the TCP include e-mail and file
asynchronous conferencing [1]. The term can thus transfer. Among its management tasks, the TCP
mean any technology ranging from real-time online controls message size, the rate at which messages
chat over instant messaging and online forums to are exchanged, and network traffic congestion. The
fully immersive graphical social environments [2]. TCP provides a communication service at an
In computing, network programming, essentially intermediate level between an application program
identical to socket programming or client-server and the Internet Protocol (IP). In other words, when
programming, involves writing computer programs an application program desires to send a large
that communicate with other programs across a chunk of data across the Internet using IP, instead
computer network. The program or process of breaking the data into IP-sized pieces and issuing
initiating the communication is called a client a series of IP requests, the software can issue a
process, and the program waiting for the single request to the TCP and let the TCP handle the
communication to be initiated is the server process. IP details [6] as shown as in fig 1.
The client and server processes together form a
distributed system. The communication between
the client and server processes may either be
connection-oriented (such as an established TCP
virtual circuit or session) [3], or connectionless
(based on UDP datagrams). A program that can act
both as a client and a server is based on peer-to-
peer communication [4].

2. TCP and UDP

The Transmission Control Protocol (TCP) is one of


the core protocols of the Internet Protocol Suite [5].
The TCP is so central that the entire suite is often
referred to as "TCP/IP." Whereas IP handles lower-
level transmissions from computer to computer as a Fig 1. Show the Communication Using TCP
message makes its way across the Internet, the TCP

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 19

A datagram socket is a type of Internet socket, message will reach the receiving application
which is the sending or receiving point for packet first. When data packets arrive in the wrong
delivery services. Each packet sent or received on a order, the TCP layer holds the later data until
datagram socket is individually addressed and the earlier data can be rearranged and
routed. Multiple packets sent from one machine to delivered to the application.
another may arrive in any order and might not
arrive at the receiving computer. The User 4. Heavyweight – the TCP requires three packets
Datagram Protocol (UDP) is one of the core just to set up a socket, before any actual data
members of the Internet Protocol Suite. The UDP can be sent. It handles connections, reliability
sends always enabled on a datagram socket. In and congestion control. It is a large transport
order to receive broadcast packets a datagram protocol designed on top of IP.
socket should be bound to the wildcard address.
Broadcasted packets may also be received when a 5. Streaming - Data is read as a "stream," with
datagram socket is bound to a more specific address nothing distinguishing where one packet ends
[7] as shown in fig 2. and another begins. Packets may be split or
merged into bigger or smaller data streams
arbitrarily.

6. The UDP is a simpler message-based


connectionless protocol. In connectionless
protocols, there is no effort made to setup a
dedicated end-to-end connection.
Communication is achieved by transmitting
information in one direction, from source to
destination without checking to see if the
destination is still there, or if it is prepared to
receive the information. With the UDP
messages (packets) cross the network in
independent units.

7. Unreliable - When a message is sent, it cannot


be known if it will reach its destination; it could
get lost along the way. There is no concept of
Fig 2. Show the Communication Using TDP acknowledgment, retransmission and timeout.

8. Not ordered - If two messages are sent to the


3. Difference between the TCP and the UDP same recipient, the order in which they arrive
cannot be predicted.
1. TCP ("Transmission Control Protocol") is a
connection-oriented protocol, which means that 9. Lightweight - There is no ordering of messages,
upon communication it requires handshaking no tracking connections, etc. It is a small
to set up end-to-end connection. A connection transport layer designed on top of IP.
can be made from client to server, and from
then on any data can be sent along that 10. Datagrams - Packets are sent individually and
connection. are guaranteed to be whole if they arrive.
Packets have definite bounds and no split or
2. Reliable – the TCP manages message merge into data streams may exist.
acknowledgment, retransmission and timeout.
Many attempts to reliably deliver the message 4. A Chat Protocol
are made. If it gets lost along the way, the
server will re-request the lost part. In the TCP, The author has made frame such as a TCP or UDP
there is either no missing data, or, in case of but which is not so big. It includes the message
multiple timeouts, the connection is dropped. body, and also some flags between them. There is
(*) and at the end of each message there is a “#“as
3. Ordered - if two messages are sent along a
shown in fig 3.
connection, one after the other, the first

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 20

Fig 4. Showing the Classification of the Message


(Private Message)

Fig 3. The content of the chat message

1. Part one represents the ID number for the


receiver. Fig 5. First, any client tries to send any
type of message. Then it is sent to the
2. Part two is the ID number for the sender. Server.

3. Part three is the message itself. Server will read the message and start its check,
check 1st the type of message if its one or two or
4. Classification of message (private or public) three to know weather its normal chat message or
request message or FTP message
5. Type of message (should be one).

4.1 The Content of the Request Message


1. Part one represents the ID number for the
receiver.

2. Part two is the ID number for the sender.

3. Type of message (should be two).

4.2 The Content of the FTP Message


1. Part one represents the ID number for the
receiver. Fig 6. The 1st login to the chat requires a check in
the data base to see if he or she has registered
2. Part two is the ID number for the sender. before.

3. Part three is the message itself.

4. Part four is the file name.

5. Type of message (should be three).

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 21

the other client windows as shown in fig 9..

Fig9. This fig showing the request was sent from the
server to the wanted client
Fig 7. If the request message is typed, then the
Fig 10 shows the case of the first. Client wanting to
request will be like this. initiate talk. He will write the message and then he
will start sending it through the server. In this case,
the message will have number one in the last field
which means that it is a chat message. The server
checks the 1st field, and if it confirms that it is one
then it will check the 2nd field. If it is one, then it is
public and there is no need to check again. In this
case, the client just broadcasts the message to the
other client. However, if the number in the 2nd field
is 2, then the server checks the 5th field and checks
its number which indicates the client number. Then,
the server sends this message to this client. When
the client reserves the message, it reads the 4th field
and checks from where the message originates and
puts it in his or her window.

Fig 8. Then the server checks this message in the


last field. If it is 2, then it is a request message

Then, the server checks this message in the last


field. If it is 2, then it is a request message. After
that, its make 2 victor one for the reserve id num
and the second one for the window itself. As shown
in fig 8, the message will be sent from the server to
the wanted reserve so that the new tab will open in

Fig 10. Showing the chat message and how the


server deals with the client.

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 22

If it is an FTP message then client one try to send a


message to client 2 through the server, the server
checks the type of message, yes it is 3 as shown in
fig 11, it checks the 5th field to verify, it is for the
wanted client. Then the server sends the messages
to the wanted client, the client cuts the message and
takes the file name and its content and saves it in
side its PC.

5. System Interfaces

System implementation is a process which is


common after the design phase. System
requirements and designs are interpreted into
software code. The detailed designs provide
information for the programmers to implement the
code. System implementation involves the
integration of individual codes from several
Fig 11. Shown as the number, if it s an FTP message, modules into complete software as well. This phase
then client one tries to send a message to will describe the initial and revised process design
implementation in the real world.

Fig 12. Showing the Data Base

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 23

Fig13. Showing the undefined person tries to login and how the system rejects it

Fig14. Showing the Client interface

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 24

Fig 15. Showing the Server Interface

Fig16. Showing the Public Message

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 25

Fig 17. Showing the User Offline and Online Contact

Fig 18. Showing the server analyzer

 
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 10, OCTOBER 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 26

CONCLUSION research would not have appeared. Finally, I would


like to express my sincere gratitude to my family for
The Communication between people is a very their help and their unconditional support. A very
special vote of thanks is due to my beloved mother.
important matter in life. For example, there are a
lot of meetings conducted between parties in
AUTHOR’S PROFILE

different parts of the world. The proposed HAMDAN ALANAZI: He has


protocol has been created for highly developed obtained his bachelor’s degree
communication levels in computer applications. from the King Saud University,
Riyadh, Kingdom of Saudi
We can use this protocol for many applications
Arabia. He worked as a
like chat programming in small companies lecturer at the Health College in
between the staff of the company. Another the Ministry of Health in Saudi Arabia, and then
worked as a lecturer at the King Saud University.
benefit of this proposed protocol is that we can
Currently, he is a Master’s candidate at the
use it for chatting between students and the class Faculty of Computer Science & Information
teacher as a type of E-Learning mechanism. The Technology at the University of Malaya in Kuala
Lumpur, Malaysia. He has published many
chat room can also facilitate very effective
articles. He is has been reviewed in many
synchronous conferencing. The Chat Protocol journals. His research interests are in
which has been presented above can help the chat Cryptography, Steganography, Digital
room to be a great success. The Chat Protocol Watermarking, Network Security, Artificial
Intelligence, pattern recognitions, signal
uses a frame such as a TCP or UDP, but it is not
processing and image processing and Medical
so big and uses another structure. Applications.

ACKNOWLEDGEMENT
This research was partially supported by the King REFERENCES
Saud University, Riyadh, Saudi Arabia, the
University of Malaya, Kuala Lumpur, Malaysia and [1] Greenberg, S. and Roseman, M., “Using a room
metaphor to ease transitions in groupware”, Sharing
“Al-Madinah International University”, Shah Alam, Expertise: Beyond Knowledge Management, 2003, P:
Malaysia. First and foremost I would like to thank 203-256.
“ALLAH” (SWT), most gracious and most merciful. [2] Zissis, D. and Lekkas, D. and Papadopoulou, A.E.,
I would like to thank Dr. Rafidah Md Noor for her “Competent electronic participation channels in
electronic democracy”, Electronic Journal of
continue support, encouragement and valuable egovernent, 2009, Vol 7(2), P: 195-208.
discussions during my research work. I also would [3] Kalajan, K.E. and Mueller, T.R. “Connection-oriented
like to express the deepest appreciation to Professor session emulation”, Google Patents, 1999.
Abdullah Ben Abdul-Rahman Abdullah Al- [4] Ford, B. and Srisuresh, P. and Kegel, D., “Peer-to-peer
Othman, Dr. Ali ibn Sulaiman Al-Attiyah and Prof. communication across network address translators”,
USENIX Annual Technical Conference, 2005.
Dr. Mohammad Khalifa Al-Tamimi. My thanks are
[5] Bellovin, SM, “Security problems in the TCP/IP
also extended to Dr. Ali bin Abdullah Alafnan, Dr. protocol suite”, ACM SIGCOMM Computer
Abdullah Alsbail, Dr. Muhammed Al Arifi, Dr. Communication Review, 1989, Vol 19 (2), P: 32-48.
Musaed AL-Jrrah, and Mr. Abdullah Alsbait. [6] Stevens, W.R. and Wright, G.R., “TCP/IP Illustrated:
Dr.Khalid Alhazmi, Mr. Seraj, Mr. Khalid and all the protocols”, Addison-Wesley, 1994.
the staff in the King Saud University especially in [7] Postel, R.J.,” User datagram protocol”, Citeseer, 1980.
Applied Medical Science for their unlimited
support. Without their notes and suggestions this

Das könnte Ihnen auch gefallen