#include "utilities/soc_lib.c" int soc;
soc = makeConnect( "localhost", socno );Where socno is an integer socket number, such as 13330 .
sprintf(message,"%f %f", x, y ); send_soc( soc, message );(You can also write to the file at the same time by adding: fprintf(plotfile,"%s\n",message); ) (Note that you can send any XGRAPH command through the socket that you would normally write to a plot-file, such as: color=8 next_line annotation 3.0 5.6 Any text you want etc.. )
close_soc( soc );
-lsocket -lnslto the end of your compile command. For example:
cc test.c -lsocket -lnsl -o test.exe(On Linux, -lnsl is not needed.)
xgraph -x_range 0 20 -y_range 1 10 -soc 13330 &
sim.exe
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.
int soc1, soc2;
soc1 = makeConnect("localhost",13330);
soc2 = makeConnect("localhost",13331);
Then start separate graphs:
xgraph -x_range 0 2 -y_range 1 9 -soc 13330 & xgraph -x_range 0 2 -y_range 1 9 -soc 13331 &
xgraph -x_range 0 2 -y_range 1 9 -soc 13330 -soc 13331 &
On Solaris: cc livetest.c -lsocket -lnsl -o livetest
On Linux: cc livetest.c -o livetestTry it by:
xgraph -soc 13330 -x_range 0 10 -y_range 0 7 -pl &
livetest