| Smith, Andrew | |
|
Java Socket Chat
Andrew Smith
December, 2002 Professor Rebecca Bruce
Description:? For my senior project I chose a windows based chat application.? In fact, the program is a chat application, but in a working environment may bear more resemblance to an instant messaging application.? The initial idea sprang from a need to connect directly with other students living on campus, who accessed the campus network.? The program was designed with the UNCA campus in mind, but will of course connect any two computers with a valid IP address connected to the Internet. Notice, only two users may connect, and must run the program simultaneously.??
Implementation: The chat application was written entirely with the java programming language, version 1.3.1.? This language was chosen because of the built in socket class ? very useful for this type of network application.? This method was also chosen to gain experience within the language, since this student had little practical experience with java, and none with sockets.? In essence the java chat program has two parts:? actual socket connectivity, and a straightforward graphical user interface.? In programming the application, the two parts were implemented separately, later combined for the final version.? Using the socket class requires a Server socket to listen for a client; when a client tries to connect the Server socket accepts the client and establishes the connection.? To accomplish this without a dedicated server, the application needs two threads; a thread for sending messages (acting as the client) and a thread for receiving messages (acting as the server).? The receive thread is started first, as would happen with a dedicated server.? It awaits the send thread, and when the send thread is started the receive thread accepts the send socket.? In this way the connection is made.? The GUI then serves as input and output for the users.?
Summary: A chat program between students is something personally useful, and fulfilled a desire to experiment in java with a networking application.? Also, the portability of java applications will help this program exist in a less narrow environment than the UNCA campus only, and also allow for growth within the program.? The project was a great learning experience, and expansions to the core program are already planned.? |
|