Code Monkey home page Code Monkey logo

java_socket_practice's Introduction

Java Socket Practice

본 자료는 자바 기반의 소켓 프로그래밍입니다.

제대로 된 예제를 실행하기 위해서는 제 Github 소스코드를 참고해 주세요

UI 기반으로 된 코드(javafx기반)를 확인하고 싶으시다면 여기를 참고해주세요.

소스코드 실행 순서는 ServerTest -> ClientTest1,2 순서로 실행하시면 cli에서 확인하실 수 있습니다.

동작 방식

구조

  • 서버
    1. 서버 실행
      • cpu 코어 수 만큼 스레드 생성
    2. 클라이언트가 접속할때까지 대기
      • 접속시 커넥션 리스트에 추가
    3. 클라이언트가 서버에 접속
    4. 클라이언트가 메세지 전송
      • 서버에 연결된 모든 클라이언트에게 다시 메세지 전달
  • 클라이언트
    1. 서버에 접속
      • 접속과 동시에 계속 받기 위해 대기 중
    2. 메세지 전송
      • 서버로 메세지 전송

사용한 라이브러리

  • 입출력 관련
    • InputStream
    • OutputStream
  • 소켓 관련
    • InetSocketAddress
    • ServerSocket
    • Socket
  • 스레드 세이프 관련
    • Vector
  • 스레드 관련
    • ExecutorService
    • Executors

참고자료

  • 이것이 자바다

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.