Skip to content

A repo about the projects I made using sockets in C as some side fun projects

Notifications You must be signed in to change notification settings

Gamin8ing/sock-apps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socket Programming Projects

A collection of socket-based applications showcasing the fundamentals of network communication. This repository contains the following two projects:

  1. Webserver: A lightweight web server built in C to serve static web pages.
  2. Chat Application: A real-time chat application implemented in C using sockets for client-server communication.

Note

Both the application has multithreading implemented for multi user access and handle multiple connections.


Table of Contents


Webserver

Features

  • Serves static HTML files to clients over HTTP.
  • Handles basic HTTP GET and POST requests.
  • Multithreaded to handle multiple client requests simultaneously.
  • Simple to configure and run.

Usage

  1. Compile the webserver:
    gcc webserver.c -o webserver
  2. Run the server:
    ./webserver
  3. Access the server via a browser or a tool like postman:
    http://localhost:<port>
    

Tip

Use -lpthread if you get hit with a warning that pthread is undefined


Chat Application

Features

  • Real-time, text-based messaging between multiple clients.
  • Server handles concurrent clients using threads.
  • Lightweight and efficient implementation using low level C sockets.

Demo

Usage

  1. Compile both server and client:

    gcc server.c -o server
    gcc client.c -o client
  2. Start up the server by just:

    ./server
  3. Start the client with whatever PORT that isn't busy:

    ./client <port-numeber>
  4. Create multiple clients in different windows to access multiple chat clients.


Project Structure

.
├── webserver/
│   ├── webserver.c        
│   ├── index.html        
│   └── webserver           
├── chatapp/
│   ├── server.c
│   ├── server    
│   ├── client.c    
│   └── client           
└── README.md               

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/your-username/socket-programming-projects.git
    cd socket-programming-projects
  2. Follow the instructions in the Webserver and Chat Application sections to run the projects.


Contributing

Contributions are welcome! To contribute:

  1. Fork this repository.
  2. Create a feature branch:
    git checkout -b feature/your-feature-name
  3. Commit your changes:
    git commit -m "Add your feature description"
  4. Push to your branch:
    git push origin feature/your-feature-name
  5. Open a pull request.

Author

Developed by Bhavya Gupta (aka Gamin8ing).

About

A repo about the projects I made using sockets in C as some side fun projects

Topics

Resources

Stars

Watchers

Forks