5 Socket - load the C socket.h defines
11 $proto = (getprotobyname('udp'))[2];
12 socket(Socket_Handle, PF_INET, SOCK_DGRAM, $proto);
16 This module is just a translation of the C F<socket.h> file.
17 Unlike the old mechanism of requiring a translated F<socket.ph>
18 file, this uses the B<h2xs> program (see the Perl source distribution)
19 and your native C compiler. This means that it has a
20 far more likely chance of getting the numbers right.
24 Only C<#define> symbols get translated; you must still correctly
25 pack up your own arguments to pass to bind(), etc.
34 @ISA = qw(Exporter DynaLoader);
117 ($constname = $AUTOLOAD) =~ s/.*:://;
118 $val = constant($constname, @_ ? $_[0] : 0);
120 if ($! =~ /Invalid/) {
121 $AutoLoader::AUTOLOAD = $AUTOLOAD;
122 goto &AutoLoader::AUTOLOAD;
125 ($pack,$file,$line) = caller;
126 croak "Your vendor has not defined Socket macro $constname, used";
129 eval "sub $AUTOLOAD { $val }";
134 # pack a sockaddr_in structure for use in bind() calls.
135 # (here to hide the 'S n C4 x8' magic from applications)
137 my($af, $port, @quad) = @_;
138 my $pack = 'S n C4 x8'; # lookup $pack from hash using $af?
139 pack($pack, $af, $port, @quad);
145 # Preloaded methods go here. Autoload methods go after __END__, and are
146 # processed by the autosplit program.