Coder Social home page Coder Social logo

java-socket-program's Introduction

Java-Socket-Program ๐Ÿ”Œ

This is a basic program to show to connect the socket.

Java Socket Programming Process

Java socket programming allows for the communication between two applications running on different Java Runtime Environments (JRE). This typically involves a client-server communication model where a server socket listens for incoming client connections and responds accordingly.

Key Components:

  1. Socket: An endpoint of a two-way communication link between two programs running on the network [citation:2][citation:6].
  2. ServerSocket: This class is used to create a server socket that waits for client requests and establishes a connection [citation:5][citation:8].

Connection-Oriented Socket Programming:

  1. The ServerSocket listens on a specified port and waits for client connections using the accept() method.
  2. The Socket object represents the client's endpoint and is created by the client program to connect to the server [citation:3][citation:7].

Communication Steps:

  1. Server Side:

    • Create a ServerSocket and wait for connections.
    • Upon accepting a connection, a Socket object is created to handle communication with the client.
    • Use input and output streams to read and write data.
    • Close the socket once the communication is complete.
  2. Client Side:

    • Create a Socket to connect to the server.
    • Use input and output streams to read and write data.
    • Close the socket once the communication is complete [citation:9][citation:10].

Diagram

Server-Client Communication Flow:

Client       Server
  |             |
  |   Socket    |
  |------------>|
  |             |
  |   .accept() |
  |<------------|
  |             |
  | Input/Output |
  |------------->|
  |<-------------|
  |             |
  |  .close()   |
  |------------>|

java-socket-program's People

Contributors

xshbi 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.