No description
Find a file
toki d89b25948a feat: SSL/TLS support for both client and server
- ProtobufServer: named constructor .secure() for SSL mode
  - SecurityContext parameter for certificate/key loading
  - SecureServerSocket 분기 처리, stop()에서 양쪽 close
  - isSecure getter 추가
- ProtobufClient: static factory 메서드 추가
  - connect() — plain TCP
  - connectSecure() — SSL/TLS (SecureSocket extends Socket이라 내부 무수정)
- 테스트: SSL 그룹 4개 추가 (총 13개, 전부 통과)
  - 자체 서명 인증서로 실제 SSL 연결 검증
  - plain / SSL 동일 시나리오 병렬 커버

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 13:56:32 +09:00
dart feat: SSL/TLS support for both client and server 2026-04-05 13:56:32 +09:00
.gitignore docs: add Python and Rust to planned implementations 2026-04-05 13:46:20 +09:00
PROTOCOL.md docs: add Python and Rust to planned implementations 2026-04-05 13:46:20 +09:00
README.md docs: add Python and Rust to planned implementations 2026-04-05 13:46:20 +09:00

Toki Socket

Binary TCP socket protocol library for bidirectional, heterogeneous communication across languages and platforms.

Built on Protocol Buffers with a fixed 4-byte length-prefixed framing, type-based message routing, and built-in heartbeat.


Protocol

See PROTOCOL.md for the full wire format specification.

[4-byte big-endian length] [PacketBase protobuf bytes]

Implementations

Language Status Path Use case
Dart Available dart/ Flutter, Dart server
C# Planned csharp/ Unity, .NET
Kotlin Planned kotlin/ Android
Swift Planned swift/ iOS, macOS
Python Planned python/ Server, tooling, scripting
Rust Planned rust/ High-performance server, embedded

Quick Start (Dart)

import 'package:toki_socket/toki_socket.dart';

// 1. Define your message in message_common.proto, generate with protoc

// 2. Implement a client
class MyClient extends ProtobufClient {
  MyClient(Socket socket) : super(socket, 30, 10, {
    MyMessage.getDefault().info_.qualifiedMessageName: MyMessage.fromBuffer,
  });
}

// 3. Implement a server
class MyServer extends ProtobufServer {
  MyServer() : super('0.0.0.0', 9090, (socket) => MyClient(socket));

  @override
  void onClientConnected(ProtobufClient client) {
    client.addListener<MyMessage>((msg) => print('Received: ${msg}'));
  }
}

// 4. Start
final server = MyServer();
await server.start();

// 5. Connect and send
final socket = await Socket.connect('localhost', 9090);
final client = MyClient(socket);
await client.send(MyMessage()..text = 'hello');

Adding Message Types

Edit dart/lib/src/packets/message_common.proto and regenerate:

cd dart
dart pub global activate protoc_plugin
protoc --dart_out=lib/src/packets lib/src/packets/message_common.proto

Running Tests

cd dart
dart pub get
dart test