Skip to content

Basic server/client networking #22

Description

@marceline-cramer

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions