Skip to content

Basic server/client networking #22

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

Open
marceline-cramer opened this issue Jul 7, 2021 · 2 comments
Open

Basic server/client networking #22

marceline-cramer opened this issue Jul 7, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@marceline-cramer
Copy link
Contributor

Here's a bare minimum network story:

  • you start one mdo-cli with a --server command-line argument (server)
  • you start another mdo-cli without that argument (client)
  • the client connects to the server, and sends it a username (ExampleUsername for now)
  • the server logs that connected username to the console
  • the server sends out that username to all of the already connected clients
  • the clients log out that username

There's no immediate need to use an advanced protocol definition format like FlatBuffers, so for this basic demo, sending simple strings in packets is fine. Remember to appropriately handle null termination.

Other than the --serverless flag passed to the CLI to select whether the server or the client is running, there's no need to provide any other configuration to the CLI to get a basic networking demo working. That can be figured out in a future issue. For now, hardcoding a localhost address and port, and using a hard username like ExampleUsername is fine.

Physical implementation:

  • create network_client and network_server objects:
    • include/network/network_server.h
    • include/network/network_client.h
    • src/network/network_server.c
    • src/network/network_client.c
  • use libuv in network_server to listen on a localhost port, handle incoming clients and safely handle remote hang-ups
  • format and log strings received by network_server (like "ExampleUsername connected") and broadcast them back out to clients
  • use libuv in network_client to connect to a localhostport, and log received strings
  • in cli/main.c, scan the arguments for --serverless using strcmp(), and initialize either network_server or network_client depending on presence of the flag
@MilesLitteral
Copy link
Contributor

Closed as of 7/13/21 meetup and review of the codebase?

@marceline-cramer
Copy link
Contributor Author

marceline-cramer commented Jul 14, 2021

Closed as of 7/13/21 meetup and review of the codebase?

No, usernames still can't be sent over and logged yet... we can make more plans at the next meeting, but the code itself isn't ready.

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

No branches or pull requests

2 participants