in reply to Socket problems under Windows

First off, I'm going to go out on a limb and guess that this is some DOS based system. There are numerous problems with running perl on this platform, and one of which is open file handles. Windows9x has limitations to the number of handles it can have open at any one particular time. If there are two many open, then you will not be able to get any more until system resources are free. Handles in Win32 can count as: I'm not sure exactly what the upper limit is, but it seems that you are hitting it. You may need to make a few tweaks to get this to run. It is quite possible that with all the junk you have running, perl does not have the space to create file handles. Perl has to open a lot of files to get a program up and running, and that may be an issue. If you are using C, all you have to do is open up one file, and launch a socket.

Here are my suggestions on getting it to run. First off, make sure that you have a working IO::Socket program. You didn't post any here, so I'm assuming you have one that works. Here's a really quick and dirty one that doesn't want to do anything complicated.
#!/usr/bin/perl -w use strict; use IO::Socket; my $sock = IO::Socket::INET->new(PeerAddr => 'www.perlmonks.org', PeerPort => 'http(80)', Proto => 'tcp') or die "Ack! No so +cket!"; $sock->write("GET /\r\n\r\n"); my $foo; $sock->read($foo, 1000000); print $foo."\n";
Okay, does that run? If it does, than you're hitting the upper limit on complexity in the program. Here are my suggestions if it doesn't: It's a tough problem if Windows is going to cough at you, but it's quite possibly Novell or the Anti-Virus's part. Reboot the box and see if it works after a cold reboot.

    --jb

Replies are listed 'Best First'.
Re: Re: Socket problems under Windows
by blogan (Monk) on Apr 15, 2002 at 13:36 UTC
    I've stripped my code down to this:
    use Socket; my $proto = getprotobyname('tcp'); socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!\n"; print "Good\n";
    And that won't even work. I set FILES=200 and it was originally set to 150. Win32::Internet won't work because I can't use it at a socket level. The boxes do have TCP installed. Like I said, somehow Java can open up a socket and communicate. Of course, Java may be able to open sockets under Novell somehow. The machines are Windows 98. Also, rebooting will not help. Deep Freeze is installed, so you could wipe out the entire file system, install any program, delete registry keys and the machine we be the same as before after reboot. Maybe I'll write a small script that does a bunch of OPEN calls and see how many I can do there. Of course, the code does work on my box at home (98) and a laptop I borrowed (XP), so it must be something either with Novell or something else.
      Read at Perl 5 by Example (David Medinets-1997): Check the values returned at $proto. You should write all the get...() like this... my $proto = getprotobyname('tcp)||6; ##just in case you don't get any value as returned... hope it helps Alberto