serial port to poll on request

This is a discussion on serial port to poll on request within the C++ Programming forums, part of the General Programming Boards category; I currently have two programs("reading" and "writing") and each program run on one PC to do textfile transferring/logging. The PCs ...

serial port to poll on request

I currently have two programs("reading" and "writing") and each program run on one PC to do textfile transferring/logging. The PCs is connected via a null modem cable. The program is running in windows and is a DOS application written in c++. The programs work but it is working in a way that i have to run the "reading" program first to let it poll before i can run the "writing" program to send the content of the text file.

How do i make it in a way that the "reading" program will only start polling upon request from the "writing" program? Meaning, when i clicked the "writing" program to send the data, it will communicate with the "reading" program to start and get ready to receive.

This is my codes for the "reading" side (Upon receiving the content from the "writing" side, it will log it into a text file called "new.txt")

Uh, if it's a DOS program, why are you including Windows.h? The black box of fun that comes with Windows XP isn't really DOS...

You might want to make sure you understand what you're programming for, before you get too much into it. This technically isn't a C++ issue, so this may get thrown into another section of the forums by the moderators.

I know that this is just a small program but how do i make the "reading" program poll only when the "writing" program is trying to send data?

In general, that statement is just about 100% backwards. In almost all data servers, serial, Ethernet, whatever, the READER (Client) sends out poll messages, and the WRITER (Server) responds to them.

You should have your 'Writer' sit and wait for a go-ahead sequence of characters from the reader, before it begins spewing forth data. That way, start up order isn't important.

You also need the bidirectional communications in both programs, and should probably do transfers in discrete blocks, so that you can detect errors (simple block checksums can work here), and re-transmit blocks as required.