Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tcp protocol #27

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

marverlous811
Copy link

What

This PR adds TCP protocol for the MIO backend

Change

The significant change is file src/backend/mio.rs, which adds logic for TCP protocol.

  • I created TcpListenerContainer to keep the TCP listener. If one connection is connected to the TCP listener, it will save TcpStreamContainer inside it.
  • Because each connection needs to register with the poll as a unique event source, I added an addr_seed_to_token function to create its unique token. That function will generate a token by using the listener port and its connection seed (incrementally when the listener has a new connection).

How to test

  • exec RUST_MIN_STACK=6400000 RUST_LOG=info cargo run --example tcp_echo_server command to start the TCP server.
  • using the telnet command to connect to that TCP server as a client.

QA

  • Why will the event_buffer pop in the next tick instead of instantly after it is processed?

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 69.82759% with 70 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (main@10f6b9e). Click here to learn what that means.

Files Patch % Lines
src/backend/mio.rs 76.41% 50 Missing ⚠️
src/task.rs 0.00% 20 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #27   +/-   ##
=======================================
  Coverage        ?   52.40%           
=======================================
  Files           ?       13           
  Lines           ?     1374           
  Branches        ?        0           
=======================================
  Hits            ?      720           
  Misses          ?      654           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant