Protocol overview
The P4API is built into Helix Core clients, such as the P4 command line client and the Helix Core Visual Client (P4V).
The P4ALTSYNC protocol is the communication protocol between the P4API and the P4ALTSYNC agent.
This functionality was introduced in the 2023.1 release of P4API and requires a 2023.1 Helix Core Server.
The P4API communicates with the P4ALTSYNC agent over either STDIO or named pipes defined by the value of the P4ALTSYNC
environment variable:
- If set to the path of an executable program or script, that executable will be launched and commands will be sent to the process’s STDIN and responses read from STDOUT
- If set to a named pipe path (prefixed with
pipe:
), the pipe will be opened and commands written to the pipe and responses read from it.
All commands and responses are single-line JSON structures:
-
The commands always have an
altSync
key with the command as the value. Details are documented in the Protocol reference. -
The responses always have a result key with a boolean success value (true is success) or string value of
success
,error
orpass
(see chmod, move and delete for details ofpass
). If the result is not success, an error string may be provided. Some commands may expect other fields too.Example success:
{"result":true}
Example failure:
{"result":false,"error":"Unknown P4ALTSYNC command!"}
Protocol support
The P4ALTSYNC JSON Protocol for writing your own client for a file virtualization service is fully supported. (The Technical Preview applies solely to the agent implementation that Perforce provides.)