Go port for PtyTerminal: ptyterminal-go
English | 简体中文
cross platform Pseudo Terminal (PTY) Library and Usage Demos in .NET(C#)
Pty.Net cross platform Pseudo Terminal (PTY) Library in .NET(C#). Modified from microsoft/vs-pty.net and inspired by WindowsGSM/SteamCMD.ConPTY.
- Compatibility with
ConPTYandwinptyon Windows Platform - P/Invoke APIs (
forkptyioctlkill...) on Unix Platforms- APIs provided by
libc.so.6andlibutil.so.1for Linux - APIs provided by
libSystem.dylibfor MacOs
- APIs provided by
- PtyCli Console demo to use Pty.Net
- PtyWeb.EmbedIO Web demo to use Pty.Net, powered by EmbedIO and Xterm.js
- Run:
dotnet run --project examples/PtyWeb.EmbedIO(default http://localhost:8877)

- Run:
- PtyWeb.AspNetCore WebSocket server demo based on WebSockets support in ASP.NET Core
- Same frontend and wire protocol as the EmbedIO demo: text frames are pty input, binary frames are JSON commands (e.g. resize)
- Run:
dotnet run --project examples/PtyWeb.AspNetCore(default http://localhost:8878, WebSocket at/terminal)
- PtyWeb.SignalR Server demo based on ASP.NET Core SignalR
- Hub methods: client calls
Input(string)/Resize(cols, rows); server pushesOutput(byte[])/Closed(exitCode) - Run:
dotnet run --project examples/PtyWeb.SignalR(default http://localhost:8879, hub at/terminalHub)
- Hub methods: client calls
- PtySession pty session management demo based on WebSockets support in ASP.NET Core
- Sessions outlive the browser connection: closing the page keeps the pty running on the server; reopen the page, pick the session from the list and resume xterm interaction (64KB output replay on attach)
- Sessions are destroyed explicitly by the client, or automatically when the pty exits (e.g. typing exit)
- Wire protocol: binary frames are JSON commands (list/create/attach/detach/destroy/resize), text frames are pty input, binary frames are pty output (including replay)
- Run:
dotnet run --project examples/PtySession(default http://localhost:8880, WebSocket at/terminal)
-
Always flush input: WriterStream is a PipeStream implementation (internally buffered); call FlushAsync after writing or the input will not reach the pty. Use the PtyStreamExtensions.WriteInputAsync helper (write + flush) to avoid losing input.
-
Each example project is self-contained (code duplication is intentional) so it can be read and modified independently
-
To exit PtyCli, exit the shell inside the pty normally (e.g. type
exit); Ctrl+C is forwarded to the pty child program as a key press -
Default ports: EmbedIO
8877, AspNetCore8878, SignalR8879, PtySession8880; all can be overridden with the first command line argument, e.g.dotnet run --project examples/PtyWeb.SignalR -- http://*:9000
