Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

socket programming

by hmvasista (Novice)
on Jul 10, 2016 at 22:34 UTC ( [id://1167538]=perlquestion: print w/replies, xml ) Need Help??

hmvasista has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to "use Socket" in my code. But I am getting this error:


Can't load 'C:/strawberry/perl/site/lib/auto/Socket/Socket.dll' for module Socket: load_file:%1 is not a valid Win32 application at C:/strawberry/perl/site/lib/ XSLoader.pm line 70.
at C:/strawberry/perl/site/lib/Socket.pm line 859.
Compilation failed in require at temper.pl line 3. BEGIN failed--compilation aborted at temper.pl line 3.


My code:


use strict; use warnings; use Socket; my $protocol = getprotobyname("tcp"); print $protocol; socket(my $socket, PF_INET, SOCK_STREAM, $protocol);

How can I fix this?

Replies are listed 'Best First'.
Re: socket programming
by Cow1337killr (Monk) on Jul 11, 2016 at 00:04 UTC

    The perl code that you provided runs with no complaints on my machine.

    This is perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32-x86-multi-thread-64int

    If I try to install the Socket module, I am told:

    Socket is up to date (2.021).

    If I look in C:\Strawberry\perl\lib\auto\Socket\, I see:

    Socket.xs.dll

    Upon further research, I find that the Socket module is in the list of Perl core modules.

      yes, I have installed the v5.24 too. At C:\strawberry\perl\site\lib\auto\Socket I see the following files: .packlist, Socket.bs, Socket.dll, I don't see Socket.xs.dll. Is there anything I am missing?

        .packlist, Socket.bs, Socket.dll, I don't see Socket.xs.dll

        The files you're seeing are not from Strawberry 5.24. They are part of a much older version.
        ".bs" files are no longer installed, and Strawberry now builds ".xs.dll" files instead of ".dll".

        Your problem will go away if you remove that Socket installation (in its entirety) from perl/site/lib.
        That will enable perl/lib/Socket.pm (which shipped with Strawberry) to be loaded - and all should work fine.

        However, it's likely that there are other extensions from the older perl present in perl/site/lib.
        Removing everything from the perl/site/lib folder is a valid option.
        That folder is normally empty when perl is installed - the only modules that go into it are the ones that you subsequently install (or, as in your case, the files that were there from a previous installation :-)

        Cheers,
        Rob
Re: socket programming
by Anonymous Monk on Jul 10, 2016 at 23:29 UTC

    Which version of strawberryperl are you running, which file did you download?

        Which version of windows are you running?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-20 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found