Alireza-Razavi / SimpleJavaChat

Java socket programming is shown in this simple chat application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Directories

  • release
    The release version of the project (no need to build project from source)
  • client
    The source code for client app written in NetBeans IDE using the java swing framework.
  • server
    The source code for server app written in Eclipse IDE without any GUI and should be run using the command line <path-to-your-java> -jar server.jar in a command-line interface (CLI)

Project Architecture (Diagram)

Diagram

  • The project uses TCP as transfer layer (third layer in TCP/IP)
  • JSON is used as data interchange format in this project (Application layer in TCP/IP)
  • The connection between clients and server is clear but in additional each client randomly chooses a listening port for incoming messages from other clients.
    When a client wants to establish a connection with another one, it requests the listening port of the target client from server and then connects to it. (Clients are directly chatting with each other and the server doesn't route the messages, It is possible until clients have static IP addresses and also they are all in one network)

Note: I have currently runned all clients and the server in one computer but if you want to run clients and the server in different computers, you can easily change the server ip address at this line
socketToServer = new Socket("localhost", 12345);

and change the target client (the client you are chatting with) ip address at this line
Socket socket = new Socket("localhost", port);

Demonstration

Demo

About

Java socket programming is shown in this simple chat application.


Languages

Language:Java 100.0%