Skip to content

Traffic Statistics

v2rayroot edited this page Jun 14, 2026 · 1 revision

Traffic Statistics

Statistics are available only while the runtime is running.

GetTotalTraffics

char *GetTotalTraffics(void);

Returns cumulative bytes:

{
  "uplink": 1048576,
  "downlink": 8388608
}

GetRealtimeSpeed

char *GetRealtimeSpeed(void);

Returns bytes per second:

{
  "uplinkSpeed": 12500.4,
  "downlinkSpeed": 84000.2
}

The first call establishes a baseline and normally returns zero. Poll from one task at a stable interval such as one second.

Error Result

When stopped, the result includes:

{"error":"server is not running"}

All returned strings must be released with FreeCString.

Clone this wiki locally