Could you give me some tips on how to clean up the code, If i could extend it to 1000's of connections that would be fantastic, Also would it somehow be possible to create different logs based on the ip?
Hmm. Sure, but there are some worrying signs in your questions.
Cleaning up the piece of code that you posted and making it write a separate log file for each in-bound ip is ... well, frankly easy. That is, it is a pretty simple task and anyone with a small amount of programming experience would be able to see how to do this themselves.
If you cannot see how to do that, it makes me nervous about trying to help you further as it tends to indicate that you are not looking for someone to help you, but rather looking for some to do this for you. This place is a self-help community, not a 'bespoke software for free' shop.
Here's the thing. The greatest tip for writing good multitasking code is
So, if you really just want help, not someone to write this for you, I suggest that you try and extend your original code to handle step 2 above.
You say "that works 100% basically i have a open port and it listens for connections then once a connection is established it saves all the data to a log file, ...".
As it is, each time you have something to write to a log file, you are opening that log file using the following line:
open ($log, '>>','log.txt') || die "Couldn't open log.txt: $!";
Now, that is obviously going to put all the data into a single file.
You also have a variable, my $client_ipnum = inet_ntoa($c_ip); which from the name seems to indicate that it is the ip address of the connecting client.
How do you think that you could modify your original program to write the input from different ips to different log files?
In reply to Re^3: multiple connections
by BrowserUk
in thread multiple connections
by xarex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |