How to use the serial port to make two computers talk.

I was looking for help on making two computers talk (live chat) via a connection through the serial port in C?? How can that also be modified to allow transfer of files between the two computers? Does anyone know where I can start? Any help would be appreciated.  Thanks!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well, C is platform independent language and doesn't have any standard functions you can use to communicate with hardware. Most OSs use devices to accomplish this.

You should be able to open the serial device and simply read/write it. You can usually set parameters such as baudrate using an ioctl()-like interface.

Start by setting up the connection and when that is working (ie you can send something from one computer to the other), define a communication protocol that allows for live chat, file transfer, etc.
ign0miniousAuthor Commented:
Hmm.. Would it then be wise for me to use C to perform this task. Perhaps assembly would be preferable? What would you recommend? (mtmike?)
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

There's no need to use assembly. Most OSs have C functions to access the serial port and this is the preferred method.

The links sunnycoder has given show you how to do this on a unix system. On windows:

ign0miniousAuthor Commented:

That link is for windows CE - will it be the same for other versions of windows (win2k/xp)?

Also, does anyone have any sample code of how I should even begin - I'm clueless.

reiterating what I posted
Serial Programming Guide for POSIX Operating Systems --- will work for all POSIX compliant systems and that includes windows  -- this is one of the most detailed guides.. even though it has a bias towards unix, you should find it very helpful

this is a linux link, but is a very good resoiurce and you will find it helpful
ign0miniousAuthor Commented:
Thanks for the clarification Sunnycoder,

Have you ever done something along these lines before? Do you have any sample code you can provide?
no I have not done serial programming myself
The links I posted have step by step guide along with sample code
You can either use the POSIX or the native windows API.
came across something while cleaning up
it has loads of stuff .... code, links etc
Under Windows2000 or XP, you can use the C 32bit window API.

Look for functions :

* CreateFile(..)
* WriteFile(..)
* ReadFile(..)
* DeleteFile(..)

The CreateFile function can create a handle to a communications resource, such as the serial port COM1. For communications resources, the dwCreationDisposition parameter must be OPEN_EXISTING, and the hTemplate parameter must be NULL. Read, write, or read/write access can be specified, and the handle can be opened for overlapped I/O. For more information about communications

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.