PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Text Output to Shell
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Text Output to Shell

Réponse
 
LinkBack Outils de la discussion
Vieux 23/08/2006, 01h07   #1 (permalink)
vivekian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Text Output to Shell

Hi,

I am working as an teaching assistant for a computer networking class
and have been assigned to write the server side of a small networking
application meant as an assignment for the students. The application is
meant to fulfill the following objectives :

1. Function as the server side of the application.
2. When the students are developing the client side , it should guide
them as a diagnostic tool. e.g. if they send a message and the format
is not correct , it should let them know this and indicate the correct
format.

It is a console based application where output is text. There are
multiple threads running within the application. Are there any
suggestions as to how the output messages / diagnostics messages be
displayed inorder that the different threads throwing out information
can be seperated ? The idea is to give the students the relevant
information without confusing them too much. Any suggestions would be
ful.

thanks in advance,
vivekian

  Réponse avec citation
Vieux 23/08/2006, 01h17   #2 (permalink)
Logan Shaw
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Text Output to Shell

vivekian wrote:
> I am working as an teaching assistant for a computer networking class
> and have been assigned to write the server side of a small networking
> application meant as an assignment for the students. The application is
> meant to fulfill the following objectives :
>
> 1. Function as the server side of the application.
> 2. When the students are developing the client side , it should guide
> them as a diagnostic tool. e.g. if they send a message and the format
> is not correct , it should let them know this and indicate the correct
> format.
>
> It is a console based application where output is text.


OK, but this has nothing to do with sending output to the shell.
The shell is program. Maybe you want to send output to the
terminal, which is different from the shell and which is something
the shell sends output to as well.

> There are
> multiple threads running within the application. Are there any
> suggestions as to how the output messages / diagnostics messages be
> displayed inorder that the different threads throwing out information
> can be seperated ? The idea is to give the students the relevant
> information without confusing them too much.


If you are using the stdio.h routines, or one of lots of other APIs,
you'll have to serialize access to library calls anyway. So, serialize
output, and print one line messages from each thread. At the beginning
of the line, but an indentifier (textual and symbolic, numeric,
indentation level, whatever) that shows what thread the message has
come from.

Since writing to the terminal (or to stdout) will sometimes block, if
you cannot tolerate blocking, you might be able to write messages into a
buffer (serializing access to the buffer, of course), then have another
thread whose job it is to consume data from the buffer and write it to
the terminal, or to stdout. Of course, your buffer may eventually
fill and cause blocking anyway, but maybe you can use an arbitrary
buffer or maybe you have a finite amount of data to write there.

Alternatively, you could use curses or similar and divide the screen
up into separate regions, then have each thread write to a separate
region.

- Logan
  Réponse avec citation
Vieux 23/08/2006, 08h01   #3 (permalink)
Josef Moellers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Text Output to Shell

vivekian wrote:
> Hi,
>
> I am working as an teaching assistant for a computer networking class
> and have been assigned to write the server side of a small networking
> application meant as an assignment for the students. The application is
> meant to fulfill the following objectives :
>
> 1. Function as the server side of the application.
> 2. When the students are developing the client side , it should guide
> them as a diagnostic tool. e.g. if they send a message and the format
> is not correct , it should let them know this and indicate the correct
> format.
>
> It is a console based application where output is text. There are
> multiple threads running within the application. Are there any
> suggestions as to how the output messages / diagnostics messages be
> displayed inorder that the different threads throwing out information
> can be seperated ? The idea is to give the students the relevant
> information without confusing them too much. Any suggestions would be
> ful.


I'd read your problem as
"If the client side sends a badly formatted request to the server, the
server should alert the user of this error."

That would be quite difficult to achieve, since that would require
assistance of the client which is obviously not functioning correctly.

While one could think of several possible solutions storing the error
message and requiring the student to pick it up, this would be a tricky
thing to achieve, most likely causing privacy problems (i.e. you must
prevent others to see one's errors).

Much of a robust and reasonably secure implementation relies on the
ability of the server to identify the student correctly (not in "this is
John Smith", but rather in "I'm sending this error message to the right
person"). Is each client running on a separate system, i.e. can you
identify a client by the IP-address of his/her host?

I'd think of setting up a seperate communication channel to send error
messages. In order to test their client, the students must first open
e.g. a telnet session to the server host (note that the telnet program
allows you to specify an arbitrary port!).
The server program will then create one (or more) new socket(s) with (a)
new port number(s) and tell the student which port(s) to use. Then the
student has to connect to the given port(s). The main problem here is
that this is error-prone as the students will have to copy the
port-number(s) and handle this appropriately in their client (i.e. pick
it/them up from e.g. the command line). You'd use select() to see from
which port data arrives and you'd distribute the data accordingly. As
all is handled in one thread, you can simply send the error message to
the telnet port (take care of flushing!)

HTH,
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

  Réponse avec citation
Vieux 24/08/2006, 06h55   #4 (permalink)
jasen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Text Output to Shell

On 2006-08-23, vivekian <viveklinux@gmail.com> wrote:
> Hi,



> It is a console based application where output is text. There are
> multiple threads running within the application. Are there any
> suggestions as to how the output messages / diagnostics messages be
> displayed inorder that the different threads throwing out information
> can be seperated ?


can you put the response back out the same socket that the request came in
through or put it in a log file that's identifiable by ip address etc?

--

Bye.
Jasen
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h20.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10460 seconds with 12 queries