Computer Science Homework Help

Computer Science Homework Help. server-side HTTP , client-side HTTP , JSON, I/O and multi-processing

  1. Writing your graph-making program
  2. a. As mentioned above, the URL to get will be given in a double-quoted string as argv[1]. Therefore, the first step is to remove the double-quotes.

    b. Have your program ignore Ctrl-C (SIGINT). You do not have to do this, but Ctrl-C is the way to stop simpleHttpServer.

    If you do not ignore it then when you press Ctrl-C to stop the webserver, it will also get passed along to your program too. That will stop it.

    Then when the webserver sends:

    {“command”:”quit”}

    your program will not be around to read() it. This will make the webserver upset. It will say:

    Fine! No input for you!

    c. Execute the HTTP call to get the JSON. Keep the data.

    d. Enter a loop where you will get instructions in JSON from its standard input.

    1. If the instruction your program gets is

    {“command”:”quit”}

    then to its standard output it should write:

    {“status”:”quitting”}

    and then stop the program.

    2. If the instruction your program gets is like:

    {“command”:”plot”,”xAxis”:”pl_orbper”,”yAxis”:”pl_orbeccen”}

    then to its standard output it should create the desired graph.

    Get the values for JSON variables “xAxis” and “yAxis”. Make the corresponding graph.

    how to do that?

    Personally, I recommend that you use gnuplot because it is already loaded on my system.

     Open a data file (I called mine ./data.txt. To this data file write all x-axis and y-axis value pairs where both values are given. (If one or both values are null then do not bother writing them!)

     Write a file that is a small program for gnuplot. I called mine scatter.gnu and its contents where:

     set term png size 640,480

     set output “scatterPlot.png”

     set title “pl_orbeccen as a fnc of pl_orbper”

     plot “./data.txt” with points pt 1

     quit

     gnuplot seems to like the size width: 640, height: 480, but feel free to play with those dimensions if you have the time.

     Notice I have the x- and y-axis names in the title

     fork() a child process to run /usr/bin/gnuplot. Pass the name of your gnuplot program (for me it is “scatter.gnu”) as an argument. Of course, have the parent wait() for the child.

     Send JSON back to the webserver by writing to standard output. I found I had better results when I multiplied both the height and width by 3/4: {“status”:”success”,”imageFilename”:”scatterPlot.png”,”height”:360,”width”:480}

Computer Science Homework Help

 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"