> > > Your template is wrong. You need 'x C n a4 x8' (or 'n n a4 x8').
> > Thanks, I will give that a shot. Altough, all of the docs 
> that i read
> > pack the structure with the 'S n C4 x8' template
> 
> Is that in the Perl docs somewhere?

no, they say to use sockaddr_in() of course. docs I found on google and some
old cheesy perl book :(

> 
> The first S will only work on big-endian architectures (not i386).
> 
> C4 expects four separate arguments in the range 0-255 for the 
> address, not a
> packed 4-byte string as returned by gethostbyname().

yea, i thought that seemed wrong.
 
> I suspect it "works" only by luck; you're probably using 
> INADDR_ANY on your
> bind() call, right? Is the server big-endian?

the server is a Intel P3, same as the client. Little endian. I agree, it
shouldn't work, but it does. here is the code:
--
$port = 6668;
$template = 'S n C4 x8';
$| = 1;
socket(MY_SOCKET, AF_INET, SOCK_STREAM, 0) || die "Socket: $!\n";

$addr = (gethostbyname("10.1.101.12"))[4];
$paddr = pack($template,AF_INET,$port,$addr);
bind(MY_SOCKET, $paddr) || die "$0: Cannot bind .. $!\n";
---
 
> Trying to do the pack() is just dangerous, IMO. You might get 
> it "working",
> but have it break on other machines due to endianess, for example.

yep, i agree. I learned enough here. Thanks for the help Bob!!!


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to