closing the comm port in c

S

sarath1111

hi all,
I am using comm port for serial communication between 2 PC's
using C language. Once I have initialized the COMM port, Is there any
option of closing the port in C language.
Thanks in Advance,
Sarath.B
 
W

Walter Roberson

I am using comm port for serial communication between 2 PC's
using C language. Once I have initialized the COMM port, Is there any
option of closing the port in C language.

There is no option in C itself to open a communications port.
C defines only operations on files and idealized byte streams,
not on interactive devices. Thus, any work you are doing to
initialize a communications port is platform dependant, and
the means to close the port is platform dependant as well.

Mostly (but not universally), the way to close a communications
port is to close the I/O handle associated with it.

If you are to read and write from the port by passing a FILE*
to the I/O routines, then you would likely fclose() passing in the
FILE*.

If you are to read and write from the port by passing an integer
('file descriptor') indicating the device number, then you would
likely close() passing in the integer. Note: close() is not part
of C itself, but is very common.

If you are calling special I/O routines in order to do I/O transactions
[e.g., kbin()] then you really have to check the documentation for
your platform as to how to close the device.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top