Code Monkey home page Code Monkey logo

java-socket-test's Introduction

java-socket-test

A simple Java socket client to test TCP connections to a server.

Background

When developing a notification pushing server for Android OS, a widely used method is to keep a TCP connection between server and android client. However, there are limits in Linux for how many files a process could open, so we have to optimize system configuration to improve the limits, say using "ulimit -n" to improve hard limits and soft limits. After optimizing, we need a client to test how many TCP connections a server could support, this is why this project is created.

Setting up project

This project uses Intellij IDEA as IDE and gradle as build script, to set it up, you could:

  • Fork code in github or clone the repository to your local disk;
  • Open IDEA and use "Import Project..."; Or you could run "gradle cleanIdea idea"(which maybe not work sometimes)

Usage

  • You could adjust host、port and connection limit in Main class and run main method directly;
  • Or you could run "gradle clean jar", and run "java -jar build/libs/java-socket-test.jar "

You'd better to know

  • This project will reconnect for up to 11 times if failed to connect to a server, and it will sleep for 24 hours to keep all TCP connections alive;
  • For a client, it will try to connect to server continuously without sleeping, so that you could easily get a huge number of connections quickly;
  • For a client, there might be a OS level limit for TCP connections, so if it failed, it might be a client problem instead of a server problem;
  • You'd better install this tool on different machines, say 10 PCs, so that you could get 10(clients) * 10000(connections/client)=100,000 connections.

java-socket-test's People

Contributors

aqingsao avatar

Watchers

 avatar James Cloos 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.