Git Product home page Git Product logo

paranlee / multithread-libevent-echo-server Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 4.0 38 KB

Multithreaded, libevent-based socket server.

Home Page: https://roncemer.com/software-development/multi-threaded-libevent-server-example/

License: BSD 3-Clause "New" or "Revised" License

C 78.17% Makefile 1.01% Dockerfile 5.23% Starlark 15.59%
c-server libevent event-driven mutlithreading realtime-messaging

multithread-libevent-echo-server's Issues

Handling of queued clients and timeout

Hi,

First thanks so much for sharing your code. There really are very few usable examples of multithreaded libevent that can be used as a tutorial.

I see something that I perceive as an issue. Correct me if I'm wrong.

I start a server with 2 threads on a server with 2 CPU.
I connect 3 independent telnet clients a,b,c close in time to each other to create congestion.

client a connects and echos immediately. There are messages from thread [10] on the server
client b connects and echos immediately. There are messages from thread [14] on the server
client c connects immediately (process is listening) but does not echo (event is not triggering).
I'd expect this as there are #define CONNECTION_BACKLOG 8 on the TCP socket.

I now leave client b to time out after SOCKET_READ_TIMEOUT_SECONDS 100.
Client a continues working normally. Client c is never serviced.

Now what I think is abnormal. Client b times out expires. Client c times out simultaneously and never gets serviced.

Is this expected behaviour, a bug, or a limitation in libevent?

Shouldn't the code be using something like evconnlistener_new_bind rather than listening and binding independently of libevent?

I can debug further on request if you're still maintaining this code.

best regards.

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.