[comp.lang.c] unix c help

raab@novavax.UUCP (Moshe Raab) (07/09/90)

i have been coding in c for a number of years. all of this
time i have been programming using MSC, using the MS extensions.
recently,  i installed  Mark Williams Coherent (unix like)
operating system. i started writing  my own simple communications
program but have hit some unexpected snags. for example, how does
one monitor the keyboard and the com port at the same time.
in MSC i use, kbhit(). i could theoretically write my own
kbhit in assemlby using the bios call to interrup 0x16 but
that would make it unportable. if any one has any suggestions,
please let me know.
 
also, could someone send or refer me to the source code
for a communications program?
 
i would appreciate all help.
 
thanks
 
moshe raab
(raab@novavax)

mercer@npdiss1.StPaul.NCR.COMDan Mercer) (07/10/90)

In article <1950@novavax.UUCP> raab@novavax.UUCPMoshe Raab) writes:
:i have been coding in c for a number of years. all of this
:time i have been programming using MSC, using the MS extensions.
:recently,  i installed  Mark Williams Coherent (unix like)
:operating system. i started writing  my own simple communications
:program but have hit some unexpected snags. for example, how does
:one monitor the keyboard and the com port at the same time.
:in MSC i use, kbhit(). i could theoretically write my own
:kbhit in assemlby using the bios call to interrup 0x16 but
:that would make it unportable. if any one has any suggestions,
:please let me know.
: 
:also, could someone send or refer me to the source code
:for a communications program?
: 
:i would appreciate all help.
: 
:thanks
: 
:moshe raab
:(raab@novavax)

If this truly is UNIX,  then you don't monitor the keyboard and line
in the same process - you utilize two processes - one that monitors
the keyboard and sends data to the line,  the other monitors the line and
sends data to the screen.

Or,  you could just get PCOMM from comp.sources.unix - or kermit from
same.

One of the beauties of UNIX is not having to wrestle with low level
stuff like task dispatching.

-- 

Dan Mercer
Reply-To: mercer@npdiss1.StPaul.NCR.COM (Dan Mercer)
"MAN - the only one word oxymoron in the English Language"

david@csource.oz.au (david nugent) (07/11/90)

In <1950@novavax.UUCP> raab@novavax.UUCP (Moshe Raab) writes:

>i have been coding in c for a number of years. all of this
>time i have been programming using MSC, using the MS extensions.
>recently,  i installed  Mark Williams Coherent (unix like)
>operating system. i started writing  my own simple communications
>program but have hit some unexpected snags. for example, how does
>one monitor the keyboard and the com port at the same time.
>in MSC i use, kbhit(). i could theoretically write my own
>kbhit in assemlby using the bios call to interrup 0x16 but
>that would make it unportable. if any one has any suggestions,
>please let me know.


The whole approach of polling for input should be completely
scrapped. With Unix, you have _much_ better resource usage than
sitting in an idle loop wasting machine cycles.

Basically, to do this type of thing there are a number of
different angles.  The easiest is to use multiple processes,
each to wait on the activity you're monitoring - and effectively
'sleep' while nothing is happening.  The Unix 'cu' utility is a
good example; it uses fork() to generate a child process to
accept input from the port, and echo it to the screen via
stdout.  The parent process accepts keyboard input and passes
it out the port.



-- 
_______________________________________________________________________________
 Unique Computing Pty Ltd  Melbourne  Australia  -  Communications Specialists 
        david@csource.oz.au    3:632/348@fidonet    28:4100/1@signet