Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2003-11-02
11
Medium Priority
?
1,958 Views
Last Modified: 2013-11-15
Hi,
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!
0
Comment
Question by:ign0minious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 5

Expert Comment

by:mtmike
ID: 9672404
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.
0
 

Author Comment

by:ign0minious
ID: 9675375
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?)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Expert Comment

by:mtmike
ID: 9677674
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:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceseril/html/cmconProgrammingSerialConnections.asp

0
 

Author Comment

by:ign0minious
ID: 9722394
Mtmike,

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.

Thanks!
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9722506
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
http://dns.easysw.com/~mike/serial/serial.html

this is a linux link, but is a very good resoiurce and you will find it helpful
http://www.faqs.org/docs/Linux-HOWTO/Serial-Programming-HOWTO.html
0
 

Author Comment

by:ign0minious
ID: 9722579
Thanks for the clarification Sunnycoder,

Have you ever done something along these lines before? Do you have any sample code you can provide?
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9728289
no I have not done serial programming myself
The links I posted have step by step guide along with sample code
0
 
LVL 5

Expert Comment

by:mtmike
ID: 9730124
You can either use the POSIX or the native windows API.
http://www.lookrs232.com/com_port_programming/
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9730620
came across something while cleaning up
http://www.lvr.com/serport.htm
it has loads of stuff .... code, links etc
0
 
LVL 1

Accepted Solution

by:
jimmy007 earned 1500 total points
ID: 9839350
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally wrote this article to compare SARDU and YUMI, but have now added Easy2Boot, since that is the one I currently use and find the easiest to create and alter.
The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question