Hi...
I am trying to send the data [sequence of bytes] through COM1 port to the modem. My logic on the receiving side deals with counting the characters received.
For example:
On the Sender side : I want to send 10 characters byte by byte. My Sender will send "10" as length string with say "$" as a delimiter and then send the 10 characters.
On the Receiver side : The program will receive "10" first, will convert it to integer 10 and will store it in a variable say int len. Then the program will start receiving the actual data till 10 characters are received.
I am using the blocking function of windows. So the receiving program will wait till the input buffer receives the nect byte.
My problem is that i am loosing data sometimes. So my counter on the receiving side does not matches to 10 in the above case. It always keep short of the bytes that are lost because of some reason. In this case my program keep on waiting for time till the bytes is received in the input buffer or for infinite time if no character is received.
I need a way to come out of this situation. Please help.
I thought of using threads but again the thread will consume the CPU time and may lead to the loss of data.
Also suggest if i am using a wrong approach in sending and receiving data between two external modems.
Thanks for help in advance.
Sanjay
I am trying to send the data [sequence of bytes] through COM1 port to the modem. My logic on the receiving side deals with counting the characters received.
For example:
On the Sender side : I want to send 10 characters byte by byte. My Sender will send "10" as length string with say "$" as a delimiter and then send the 10 characters.
On the Receiver side : The program will receive "10" first, will convert it to integer 10 and will store it in a variable say int len. Then the program will start receiving the actual data till 10 characters are received.
I am using the blocking function of windows. So the receiving program will wait till the input buffer receives the nect byte.
My problem is that i am loosing data sometimes. So my counter on the receiving side does not matches to 10 in the above case. It always keep short of the bytes that are lost because of some reason. In this case my program keep on waiting for time till the bytes is received in the input buffer or for infinite time if no character is received.
I need a way to come out of this situation. Please help.
I thought of using threads but again the thread will consume the CPU time and may lead to the loss of data.
Also suggest if i am using a wrong approach in sending and receiving data between two external modems.
Thanks for help in advance.
Sanjay