tcp/ip connection lost after doing an sql statement
Posted in 2003
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Networking & sqlhosts Configuration
hi all, We have a daemon program created in c which listens on a specific port for any connection request from radio frequency identifiers (rfid) after which it forks a child and the child process accepts the connection so the mother process can continue listening for other requests. the child process then parses any data coming in from the rfid and passes the values to an informix function which validates the data and returns the appropriate message back to the device (error, notfound or ok...). Our problem is that the values passed to informix somehow gets truncated even though the informix variables accepting the values have more than enough length. Also whenever we do an sql statement (insert, update, delete or create), the child process loses the connection from the rfid and then exits. Database connection is made on the c program before forking. Can someone help? Our Informix version is 7.30 and ESQL/C is 9.30
On Tue, 02 Dec 2003 07:48:05 -0500, John Anderson wrote: > hi all, > > We have a daemon program created in c which listens on a specific > port for any connection request from radio frequency identifiers (rfid) after > which it forks a child and the child process accepts the connection so the > mother process can continue listening for other requests. the child process > then parses any data coming in from the rfid and passes the values to an > informix function which validates the data and returns the appropriate message > back to the device (error, notfound or ok...). Our problem is that the values > passed to informix somehow gets truncated even though the informix variables > accepting the values have more than enough length. Also whenever we do an sql > statement (insert, update, delete or create), the child process loses the > connection from the rfid and then exits. Database connection is made on the c > program before forking. Can someone help? Our Informix version is 7.30 and > ESQL/C is 9.30 You cannot use a connection in a child that was established by the parent process! Try having the child establish it's own connection and all of your troubles should vanish. If you change the daemon to multi-thread instead of spawning a child, then the threads can share one or a pool of connections constrained only that one thread at a time can use a particular connection and that thread must make the connection DORMANT when it is finished with it before other threads can attach to that connection and use it. Check out the ESQL/C programmers manual for discussions on forking, threading, and multiple connections. Art S. Kagel