Hello,
I am using a program that reads in data from a serial port and then sends that data out over a TCP connection. The problem I'm having is that the only way I know to exit the program is to do a 'kill PID', but doing this means the program doesn't go through the motions of closing the TCP connection properly so I have to wait some random period of time for the port to free itself or else when I try to start it back up it tells me that it can't bind to the specified port.
The general structure of the program is as follows
Code:
int main(){
// initialize some stuff
// open sockets and serial ports
while(1){
// read from serial send to TCP
}
// close sockets and serial ports
}
I just need a way to trigger a 'break' in the while loop rather than killing the process. I have to run the program in background because I am running multiple instances of it for multiple serial ports/sockets. Any thoughts? thanks for your help,
-robert