Coder Social home page Coder Social logo

lindsaymergy / simplechatserver Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 647 KB

Establishes a basic chat server in Node.js using the 'net' module. This server is designed to handle client connections and facilitate communication over a TCP connection. It listens on port 8080 and displays a "server is listening" message upon initialization.

JavaScript 100.00%
chatserver net nodejs

simplechatserver's Introduction

SimpleChatServer

Establishes a basic chat server in Node.js using the 'net' module. This server is designed to handle client connections and facilitate communication over a TCP connection. It listens on port 8080 and displays a "server is listening" message upon initialization.

Explanation of functionality:

It uses the 'net' module to create a TCP server. The server listens on port 8080, and when it's ready, it logs "server is listening." The server handles client connections as follows:

  • When a client connects, it logs "client connected."
  • It sends a welcome message to the client.
  • It sets up a data event listener on the client connection to handle incoming messages.
  • When data is received from a client, it broadcasts the message to all connected clients except the sender.

TODO: handle client disconnections gracefully:

  • There's an 'end' event listener to handle client disconnections, but the implementation needs improvement. Currently t attempts to remove disconnected clients from the 'sockets' array, but there are issues with this part of the code.

simplechatserver's People

Contributors

lindsaymergy avatar

Stargazers

David Federspiel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.