Mar 24, 2004, 5:03 PM
Post #1 of 2
Hey, I'm a public school student who's doing TCP/IP Connections Using Perl as a Science Project for the local science fair. I'm fairly good at Perl for how long I've been using it (and especially good for my age), so I've been able to code a non-multithreaded and multithreaded Server connection (Non-Multithreaded was Easy, Multithreaded took a bit more time), But I'm having a bit of a problem!
I have it so each new Connection Is assigned to a Handle consisting of an array, and each new connection is assigned to a different element in the array (like 1, 2, 3, etc...). They then go through a login process using DBM files, and once they get in the server forks off a process that loops recieving data from them.. and then continues on to allow another connection! In The Reading of the data it recieves it looks at all the connections in the connection array and sends the message to them... BUT, because this is off in a different process and loop, it's not recognizing that the array is being changed, and it stays with the array it started with, allowing connectinos to send data to only connections that occured before them...
My uncle's good at Perl and advised me to use some sort of file or database other than a type of variable within the code for the connections... but when I try to make a reference to a connection in a DBM hash, something doesnt go right, and when it tries to print to it it says "cannot print to unopened filehandle"
Any Thoughts about an alternative way to do this? or If I'm doing Referencing Wrong? Or If I should try a different type of database solution? Any help would help!