Skip to content

How to use the standard api over a socket connection

silvinci edited this page Mar 17, 2012 · 3 revisions

Using a socket connection is a little different because it doesn't make sense to do it in PHP because the socket connection remains open until you close it, and that would cause the page to never load in PHP or a web browser.

This guide is language agnostic. To replicate this in any language, simply open a TCP socket and connect to your server on the port that you set in /plugins/JSONAPI/config.yml plus 1. This means the default port is 20060, since the default port set in /plugins/JSONAPI/config.yml is 20059.

The way the socket connection works is that every line sent to the server is treated as a URL. To make a standard request over a TCP socket, simply write a line like:

/api/call?method=....

The result of this call will be sent back to the client on one line followed by \r\n.