Server-Client (RPC/Web) Interfaces and ~ Environments

Modern computing extends beyond the local machine. Programs communicate across networks using Remote Procedure Call (RPC) frameworks, web protocols, and dedicated APIs. These interfaces abstract the physical machine, enabling distributed systems, cloud computing, and microservice architectures.

Remote Procedure Call (RPC)

RPC allows a program to execute a function on a remote server as if it were a local function call. The client sends a request; the server executes the procedure and returns a result.

gRPC

gRPC is a high-performance, open-source RPC framework developed by Google. It uses Protocol Buffers (protobuf) for service definitions and HTTP/2 for transport.

Features:

  • Strongly typed contracts via .proto files.
  • Bidirectional streaming.
  • Authentication, load balancing, and tracing built-in.
  • Code generation for many languages.

Example protobuf definition:

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}

JSON-RPC

JSON-RPC is a lightweight protocol using JSON for requests and responses. It is stateless and transport-agnostic (HTTP, WebSocket, TCP).

Example request:

{"jsonrpc": "2.0", "method": "get_status", "params": {}, "id": 1}

Web Interfaces

Web-based interfaces dominate modern application interaction. They use HTTP/HTTPS as the transport layer.

REST APIs

Representational State Transfer (REST) uses standard HTTP methods (GET, POST, PUT, DELETE) to manipulate resources identified by URLs.

GET    /api/users       # List users
POST   /api/users       # Create user
GET    /api/users/123   # Get user 123
PUT    /api/users/123   # Update user 123
DELETE /api/users/123   # Delete user 123

GraphQL

GraphQL provides a query language for APIs, allowing clients to request exactly the data they need.

query {
  user(id: "123") {
    name
    email
    posts {
      title
    }
  }
}

Secure Remote Access

SSH

The Secure Shell (SSH) provides encrypted remote shell access and secure file transfer. It uses public-key cryptography for authentication.

Common uses:

ssh user@host                     # Remote shell
scp file.txt user@host:/path/     # Copy file
ssh -L 8080:localhost:80 host     # Port forwarding

TLS/HTTPS

Transport Layer Security (TLS) encrypts HTTP traffic. Web servers present certificates signed by Certificate Authorities (CAs) to prove their identity.