Skip to content

meechta/Client-Server-Model-TCP-Sockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

client-server-model-tcp-sockets

Demonstration of the client server model using TCP sockets.

This program demonstrates the client-server model using TCP socket programming. A server can be started and then clients can login to that server and begin sending messages back and forth. All messages flow through the server and are then passed on to the client.

Both the Client and Server have specific commands that they can use to perform functions.

Server Features:

  • Backlog messages for logged off clients.
  • Deliver backlogged messages for newly logged in clients
  • Facilitate Blocking/Unblocking of clients
  • Update client with list of clients upon successful login
  • Keeps a total of messages sent and received for each client

Compilation

Use provided makefile

Running the program:

The program can be run in two modes, client or server with the c or s flag. Each mode requires a port number to be specified.

Example: ./client-server c 5000
This will run a client on port 5000

Example: ./client-server s 5000
This will run a server on port 5000

How to log in to server

LOGIN [SERVER IP ADDRESS] [PORT NUMBER]
LOGIN 192.168.1.50 5000

How to send a message to another client

SEND [CLIENT IP ADDRESS] [MESSAGE]
SEND 192.168.1.30 TEST MESSAGE

Available Client Commands

LOGIN - Logs client into specified server
Ex. LOGIN [SERVER IP] [SERVER PORT]

REFRESH - Obtains a new client list from the server
Ex. REFRESH

SEND - Sends a message to another client
Ex. SEND [CLIENT IP] [MESSAGE]

BROADCAST - Sends a message to all clients
Ex. BROADCAST [MESSAGE]

BLOCK - Blocks specified client IP
Ex. BLOCK [CLIENT IP]

UNBLOCK - Unblocks specified client IP
Ex. UNBLOCK [CLIENT IP]

LOGOUT - Logs client out of server. Server will save information and backlog messages
Ex. LOGOUT

IP - Displays IP client is running on
Ex. IP

PORT - Displays port client is running on
Ex. PORT

EXIT - Exits program - server will remove information for client
Ex. EXIT

Available Server Commands

IP - Displays the IP the server is running on
Ex. IP

PORT - Displays the port number the server is running on
Ex. PORT

LIST - Displays a List of all active clients. The list contains their ID-IP-HOSTNAME-PORT
Ex. LIST

STATISTICS - Display History of clients that have logged in. Statistics contains ID-HOSTNAME-MSGSENT-MSGRECVD-ONLINESTATUS
Ex. STATISTICS

BLOCKED - Displays list of clients that the specified IP has blocked.
Ex. BLOCKED [IP ADDRESS]

About

Client/Server messaging application using TCP sockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages