RE: odd perl & linux socket query problem.....

From: James Kipp (James.Kipp_at_mbna.com)
Date: 10/06/03


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
 



Relevant Pages

  • Re: General Linux c programming questions
    ... controller in c, and Windows programming experience. ... Linux process overhead is only a fraction of what it is under Windows. ... If by sockets you are referring to networking sockets, no special libraries are required. ... Socket API is included in the standard C library. ...
    (comp.os.linux.misc)
  • Re: recv blocks although socket is ready
    ... Because this is a cross plattform application for AIX, Darwin, FreeBSD, ... IRIX, IRIX64, Linux, OSF1, SunOS and Windows. ... Running the same app on the same hardware under Linux ... frequently when there is some UDP traffic on another socket. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Where do I start?
    ... > I am a newcomer to Linux development, ... > the database or server scripts into the served html pages. ... Well how would you do these tasks on Windows??? ... & 2) Just like on windows, use socket calls. ...
    (comp.os.linux.development.apps)
  • Re: A C unix server with a windows client
    ... i have written i simple C server with Socket under linux. ... problem with a unix client, but if the client is written in C under ... I believe that sockets under Windows are significantly different from ...
    (comp.lang.c)
  • Re: Future of IT in Lebanon
    ... working knowledge of Indian programmers DNA, nor of their intuitive Java ... > So Longhorn is not an experiment and Linux is an experiment? ... another chapter in the Windows story, and the Microsoft marketing machine is ... > application opens, Check the about, it says Microsoft Visual Basic 6.3. ...
    (soc.culture.lebanon)

Loading