Start XGraph with the -soc xx option, where xx is the socket your program will send data to XGraph on. Then your program should connect to that socket and send data points to plot over that socket, just as you would write lines to a file. Each line sent to XGraph through the socket must be terminated by a new-line, just as lines in a file would be.
You can send data points as well as most other commands that XGraph normally accepts from files. You can write your client applications in any language, such as C, C++, Java, Python, etc., as long as you can open a socket and write lines of characters to it. (The communications is one-way, and by using TCP/IP there is no hand-shaking needed.)
We provide a working example programs in C-language and Java that you can use. Below are some key points to writing your own client applications to plot through XGraph, using C programs as an example:
#include "soclib.c" Socket_record *soc;
soc = Setup_Client_Socket( "", socnum );Where socnum is an integer socket number, such as 13330 .
sprintf( message, "%f %f", x, y ); Send_Socket( soc, message );(Note that you can send most any XGRAPH command through the socket that you would normally write to a plot-file, such as: color = 8 next annotation 3.0 5.6 Any text you want etc.. )
Close_Socket( soc );
xgraph -x_range 0 20 -y_range 1 10 -soc 13330
livetest.exe 13330
send_soc( soc, "PAN_RIGHT\n" );This has the same effect as clicking the Pan Right button interactively. It is convenient for causing the graph to scroll horizontally as data arrives.
xgraph -x_range 0 2 -y_range 1 9 -soc 13330 -soc 13331 &
cc livetest.c -lm -o livetest.exeTry it by:
xgraph -pl -x_range 0 100 -y_range 0 1 -soc 13330 & livetest.exe 13330
javac livetest.javaTry it by:
xgraph -pl -x_range 0 100 -y_range 0 1 -soc 13330 & java livetest 13330
You can download the Java example from soc_example_java.zip.