in reply to multiple connections

Sorry xarex, what is your question:

I notice that you are opening and closing your log file all the time, but there is no need to do so (as long as each line is less than about 2kB). The file buffer handles that, and allows multiple processes to append to the same open filehandle.

hth

Clint

Replies are listed 'Best First'.
Re^2: multiple connections
by xarex (Initiate) on May 18, 2007 at 16:35 UTC
    clint, the problem is, at the moment i am writing to a single file, it may be better to write different file for different connections, because i have a php script that processes the data, how can i achieve this? thank k-
      Writing to a single file shouldn't be a problem. Do you mean that the problem is that you want to separate the data from the different connections? If so, you could prepend an ID or something to the beginning of the line to distinguish between connections:

      print $log "$connection : $buf";

      or you could use the same logic to open different files :

      open ($log,'>>',"log_$connection.txt") or die $!;

      ...where $connection is a variable that increments for every new connection that opens, or is based on the IP address, or whatever is meaningful to you.

      Have I understood the problem correctly?

      hth

      clint