Thankyou for the information.
How do you plan to deliver the service? Will the students be in a
classroom or will the service be delivered via the web / internet
browsers?
If you decide to use sockets, the interface the students use to
communicate with the server would need to use sockets but the student's
code would not require sockets to function.
Sockets in Linux behave very similarly to files. Telnet uses sockets to
connect to a remote machine but once connected any program you run on
the remote machine is not aware it is communicating with you via sockets
- as far as the remote code is concerned it is receiving input from
stdin and writing to stdout and stderr.
There are a lot of ways of delivering your proposed service. Telnet and
ftp (or the secure equivalents) provide all the functionality required
to upload files and execute compile and run commands on a remote
machine.
Alternatively, you could provide the service via a the web. Consider the
following example:
script: test.cgi
-----
#!/usr/bin/perl
$| = 1; # set unbuffered
open STDERR, ">&STDOUT"; # redirect error messages to normal output
print "Content-type: text/plain\n\n"; # notify the browser of the data
type
print "ls -l\n"; # explain what is about to be run
exec "/bin/ls", "-l"; # execute the ls command
-----
If you ran the script using a browser (e.g.
http://www.myserver.com/cgi-bin/test.cgi), the browser would display
something like the following:
ls -l
total 1
rwxr-xr-x ... ls
It would be more difficult to provide an interactive service via http
(i.e. program asks a question, student provides a response) but not
impossible.
I hope this helps. Let me know more about your requirements and I shall
help you further.
Eric Worrall
> Hello Eric,
> If I use sockets don't I have to write code for them in the
> program that I wish to send a message to? This is a problem because
> I am trying to set up a free, online compiler where a student could
> enter the source code for simple applications like "get_age", click
> a button to submit this code to the server, have the c code compiled
> on the server and get the success or
> error results back (I've got that part running),and then run their
> program (on the server) and see the results in a text area in their
> browser. They would be able to send back responses like "36" if their
> program asked for their age,etc., then wait for the response from
> their
> program such as "You are 36; what is your height:" and then enter
> their height and send that to the server for a response from their
> program, and so on.
> Wouldn't the problem with sockets be that the student would have to
> add socket code to their get_age type program, so that it could be
> compiled into it?
> Sincerely,
> Bill Northway
> > Have you considered using sockets? Sockets give a program the capacity
> > to communicate with any number of arbitrary clients, each client will
> > have a separate connection. You can use file i/o commands with sockets
> > or socket commands (send & recv) for better control. Sockets can also be
> > used for sending small 'connectionless' messages and responses.
> > Eric Worrall
--
You have just received an Etech Solution
For all your Linux requirements contact