Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Socket problems under Windows

by JayBonci (Curate)
on Apr 15, 2002 at 09:36 UTC ( [id://159119]=note: print w/replies, xml ) Need Help??


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:
  • Sockets
  • Filehandles
  • Handles to binary objects in the registry
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:
  • Close all running applications. Get a real process killer, but leave GDI, Systray, USER and explorer running. Novell and Norton are real system hogs, so if you could do without it, that may be best.
  • In your config.sys, force more handles to be created at startup. Add a line:
    FILES=255
  • Try to see if there is something else that you can use that is more specific to the task at hand, such as Win32::Internet
  • See if you program works if you move a shortcut to it into the startup folder, before items have loaded all up.
  • Are you using Winsock2? That might be something you might want to look at. If these lab machines are beyond your control, then find out what version of Winsock there is, and what can be done about it.
  • The error may be bogus. The boxes may not have TCP installed. I saw a lab once where that was the case. TCP was emulated over some bizarre Novell configuration. The perl module probably does not know how to account for it.
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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://159119]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-12-08 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.