RE: odd perl & linux socket query problem.....
From: James Kipp (James.Kipp_at_mbna.com)
Date: 10/06/03
- Next message: Kevin Pfeiffer: "RE: list-parsing problem"
- Previous message: Kevin Old: "AS2 to EDI?"
- Maybe in reply to: Fark: "odd perl & linux socket query problem....."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: 'fark' <fark987@lycos.co.uk>, beginners@perl.org Date: Mon, 6 Oct 2003 16:19:49 -0400
> use Socket;
> my $serverip = "194.109.69.91";
> my $serverport = 27960;
> my $getstatus = "\xFF\xFF\xFF\xFFgetstatus"; //THIS IS THE
> LINE I'M HAVING PROBLEMS WITH IN LINUX BEING SENT
>
> $ipaddr = sockaddr_in($serverport, inet_aton($serverip));
> $protocol = getprotobyname("udp");
>
> socket(SOCKET, PF_INET, SOCK_DGRAM, $protocol) or die "socket: $!";
> connect(SOCKET, $ipaddr) or die "connect: $!";
> send(SOCKET, "$getstatus\n", 0);
> recv(SOCKET, $response, 65000,0);
> print ($response);
>
> The weird thing is this works fine in windows and get a
> response i want, and if I packet stuff whats sent out (from
> $getstatus) the first part is FF FF FF FF which is fine,
> problem is under Linux when I run the script and sniff the
> packets going out it comes as c3 bf c3 bf c3 bf c3 bf. So
> somehow its not converting what I've entered correctly? Must
> be something obvious I'm missing?
>
The data your are sending consists of string literal values which depend on
the character set of the machine you are using. For instance, if I send
"\x01\x01\x01" to a my windows machine through a socket, I get 3 ASCII
smiley faces returned. If I send it to my linux box, I get " "/. You can
pack the data into a template where you can specify the byte order of the
data. Read up on:
perldoc perldata (section on string literals)
perldoc -f pack
- Next message: Kevin Pfeiffer: "RE: list-parsing problem"
- Previous message: Kevin Old: "AS2 to EDI?"
- Maybe in reply to: Fark: "odd perl & linux socket query problem....."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|