[29733] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 977 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 26 06:14:13 2007

Date: Fri, 26 Oct 2007 03:14:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Oct 2007     Volume: 11 Number: 977

Today's topics:
        packing a C structure  haairam@gmail.com
    Re: packing a C structure <josef.moellers@fujitsu-siemens.com>
    Re: packing a C structure <haairam@gmail.com>
    Re: packing a C structure <josef.moellers@fujitsu-siemens.com>
    Re: packing a C structure <haairam@gmail.com>
    Re: packing a C structure <haairam@gmail.com>
    Re: packing a C structure <josef.moellers@fujitsu-siemens.com>
    Re: PID of exec  hendedav@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 25 Oct 2007 21:57:55 -0700
From:  haairam@gmail.com
Subject: packing a C structure
Message-Id: <1193374675.362127.274760@i38g2000prf.googlegroups.com>

hi ,,,

iam trying to pack a C structure to send via socket..i would like to
know how to frame the template for the C structure..

this is my structure

typedef struct buffer_t {
  uint32_t a;
  char b[16];
  uint32_t c;
  uint32_t d;
  char e[6];
  char f[8];
} buffer_t;

kindly suggest me the format for the pack function call..this will
help me to solve my issue...



------------------------------

Date: Fri, 26 Oct 2007 09:06:07 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: packing a C structure
Message-Id: <ffs3l9$719$1@nntp.fujitsu-siemens.com>

haairam@gmail.com wrote:
> hi ,,,
>=20
> iam trying to pack a C structure to send via socket..i would like to
> know how to frame the template for the C structure..
>=20
> this is my structure
>=20
> typedef struct buffer_t {
>   uint32_t a;
>   char b[16];
>   uint32_t c;
>   uint32_t d;
>   char e[6];
>   char f[8];
> } buffer_t;
>=20
> kindly suggest me the format for the pack function call..this will
> help me to solve my issue...
>=20

Transferring binary structures is inherently non-portable, so there is=20
not a single way to deduce the actual binary layout of this structure,=20
as the alignment and even the format of the binary numbers (e.g.=20
endianness) will vary from machine type to machine type and even between =

compilers. It might even be impossible to transfer the data if the=20
receiving machine is unable to handle 32 bit data, but I guess that's=20
less of a problem.
That's why techniques like ASN.1 were developed.

If the amount of data is relatively small and you can live with some=20
time spent in conversion, a simple (and more portable (*)) means to=20
transfer this data is to transform it into ascii, with suitable=20
separators, e.g. commas or colons, terminated by a line feed.

(*) Sheesh, I sure hope Scott Nudds doesn't read this ;-) It's "more"=20
portable because you have removed alignment and endianness problems,=20
there's still a portability issue in that the receiving machine might=20
speak EBCDIC while the sending machine speaks ASCII.
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html



------------------------------

Date: Fri, 26 Oct 2007 00:23:37 -0700
From:  rams <haairam@gmail.com>
Subject: Re: packing a C structure
Message-Id: <1193383417.658322.93440@v29g2000prd.googlegroups.com>

On Oct 26, 12:06 pm, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
> haai...@gmail.com wrote:
> > hi ,,,
>
> > iam trying to pack a C structure to send via socket..i would like to
> > know how to frame the template for the C structure..
>
> > this is my structure
>
> > typedef struct buffer_t {
> >   uint32_t a;
> >   char b[16];
> >   uint32_t c;
> >   uint32_t d;
> >   char e[6];
> >   char f[8];
> > } buffer_t;
>
> > kindly suggest me the format for the pack function call..this will
> > help me to solve my issue...
>
> Transferring binary structures is inherently non-portable, so there is
> not a single way to deduce the actual binary layout of this structure,
> as the alignment and even the format of the binary numbers (e.g.
> endianness) will vary from machine type to machine type and even between
> compilers. It might even be impossible to transfer the data if the
> receiving machine is unable to handle 32 bit data, but I guess that's
> less of a problem.
> That's why techniques like ASN.1 were developed.
>
> If the amount of data is relatively small and you can live with some
> time spent in conversion, a simple (and more portable (*)) means to
> transfer this data is to transform it into ascii, with suitable
> separators, e.g. commas or colons, terminated by a line feed.
>
> (*) Sheesh, I sure hope Scott Nudds doesn't read this ;-) It's "more"
> portable because you have removed alignment and endianness problems,
> there's still a portability issue in that the receiving machine might
> speak EBCDIC while the sending machine speaks ASCII.
> --
> These are my personal views and not those of Fujitsu Siemens Computers!
> Josef M=F6llers (Pinguinpfleger bei FSC)
>         If failure had no penalty success would not be a prize (T.  Pratc=
hett)
> Company Details:http://www.fujitsu-siemens.com/imprint.html- Hide quoted =
text -
>
> - Show quoted text -

hi Mollers,,
Thanks for the reply.iam an beginner in perl ..still not clear how to
convert the structure into an asciii string...i was stuck with this
issue for past 2 weeks..kindly throw some guidelines for this...

regards
Rams



------------------------------

Date: Fri, 26 Oct 2007 10:18:48 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: packing a C structure
Message-Id: <ffs7te$m9e$1@nntp.fujitsu-siemens.com>

rams wrote:
> On Oct 26, 12:06 pm, Josef Moellers <josef.moell...@fujitsu-
> siemens.com> wrote:
>=20
>>haai...@gmail.com wrote:
>>
>>>hi ,,,
>>
>>>iam trying to pack a C structure to send via socket..i would like to
>>>know how to frame the template for the C structure..
>>
>>>this is my structure
>>
>>>typedef struct buffer_t {
>>>  uint32_t a;
>>>  char b[16];
>>>  uint32_t c;
>>>  uint32_t d;
>>>  char e[6];
>>>  char f[8];
>>>} buffer_t;
>>
>>>kindly suggest me the format for the pack function call..this will
>>>help me to solve my issue...
>>
>>Transferring binary structures is inherently non-portable, so there is
>>not a single way to deduce the actual binary layout of this structure,
>>as the alignment and even the format of the binary numbers (e.g.
>>endianness) will vary from machine type to machine type and even betwee=
n
>>compilers. It might even be impossible to transfer the data if the
>>receiving machine is unable to handle 32 bit data, but I guess that's
>>less of a problem.
>>That's why techniques like ASN.1 were developed.
>>
>>If the amount of data is relatively small and you can live with some
>>time spent in conversion, a simple (and more portable (*)) means to
>>transfer this data is to transform it into ascii, with suitable
>>separators, e.g. commas or colons, terminated by a line feed.
>>
>>(*) Sheesh, I sure hope Scott Nudds doesn't read this ;-) It's "more"
>>portable because you have removed alignment and endianness problems,
>>there's still a portability issue in that the receiving machine might
>>speak EBCDIC while the sending machine speaks ASCII.
>>--
>>These are my personal views and not those of Fujitsu Siemens Computers!=

>>Josef M=F6llers (Pinguinpfleger bei FSC)
>>        If failure had no penalty success would not be a prize (T.  Pra=
tchett)
>>Company Details:http://www.fujitsu-siemens.com/imprint.html- Hide quote=
d text -
>>
>>- Show quoted text -
>=20
>=20
> hi Mollers,,

No offence, but my first name is "Josef". (We have these problems=20
ourselves with people from e.g. Japan ;-)

> Thanks for the reply.iam an beginner in perl ..still not clear how to
> convert the structure into an asciii string...i was stuck with this
> issue for past 2 weeks..kindly throw some guidelines for this...

As usual, TMTOWTDI:

if you have the socket open, e.g. in $sock, just do

*** Sender ***
my $data =3D join(':', $a, @b, $c, $d, @e, @f);
print $sock $data, "\n";

*** Receiver ***
my $data =3D <$sock>;
chomp $data;
my @data =3D split(/:/, $data);
$a =3D $data[0];
@b =3D @data[1..16];
$c =3D $data[17];
$d =3D $data[18];
@e =3D @data[19..24];
@f =3D @data[25..32];

You could also use some kind of tagging:

*** Sender ***
print $sock "a=3D$a\n";
foreach (0..15) {
     print $sock "b$_=3D$b[$_]\n";
}
=2E..
print $sock "\n";

*** Receiver ***

while (<$sock>) {
     if (/^a=3D(\d+)/) {
	$a =3D $1;
     } elsif (/^b(\d+)?(\d+)/) {
	$b[$1] =3D $2;
     } ... {
     } elsif (/^\s+$/) {
	last;
     }
}

Maybe XML could be used.

You may also want to have a look at pack/unpack. They have data types=20
which are pretty well defined (e.g. L is an unsigned long of exactly 32=20
bits).

It's all a matter of
1. what you feel comfortable to use
2. what is most stable
3. what is best maintainable
4. what is fast
5. what takes little space

Obviously others will have more elegant solutions.

Josef
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html



------------------------------

Date: Fri, 26 Oct 2007 01:49:14 -0700
From:  rams <haairam@gmail.com>
Subject: Re: packing a C structure
Message-Id: <1193388554.659482.86820@q5g2000prf.googlegroups.com>

On Oct 26, 1:18 pm, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
> rams wrote:
> > On Oct 26, 12:06 pm, Josef Moellers <josef.moell...@fujitsu-
> > siemens.com> wrote:
>
> >>haai...@gmail.com wrote:
>
> >>>hi ,,,
>
> >>>iam trying to pack a C structure to send via socket..i would like to
> >>>know how to frame the template for the C structure..
>
> >>>this is my structure
>
> >>>typedef struct buffer_t {
> >>>  uint32_t a;
> >>>  char b[16];
> >>>  uint32_t c;
> >>>  uint32_t d;
> >>>  char e[6];
> >>>  char f[8];
> >>>} buffer_t;
>
> >>>kindly suggest me the format for the pack function call..this will
> >>>help me to solve my issue...
>
> >>Transferring binary structures is inherently non-portable, so there is
> >>not a single way to deduce the actual binary layout of this structure,
> >>as the alignment and even the format of the binary numbers (e.g.
> >>endianness) will vary from machine type to machine type and even between
> >>compilers. It might even be impossible to transfer the data if the
> >>receiving machine is unable to handle 32 bit data, but I guess that's
> >>less of a problem.
> >>That's why techniques like ASN.1 were developed.
>
> >>If the amount of data is relatively small and you can live with some
> >>time spent in conversion, a simple (and more portable (*)) means to
> >>transfer this data is to transform it into ascii, with suitable
> >>separators, e.g. commas or colons, terminated by a line feed.
>
> >>(*) Sheesh, I sure hope Scott Nudds doesn't read this ;-) It's "more"
> >>portable because you have removed alignment and endianness problems,
> >>there's still a portability issue in that the receiving machine might
> >>speak EBCDIC while the sending machine speaks ASCII.
> >>--
> >>These are my personal views and not those of Fujitsu Siemens Computers!
> >>Josef M=F6llers (Pinguinpfleger bei FSC)
> >>        If failure had no penalty success would not be a prize (T.  Pra=
tchett)
> >>Company Details:http://www.fujitsu-siemens.com/imprint.html-Hide quoted=
 text -
>
> >>- Show quoted text -
>
> > hi Mollers,,
>
> No offence, but my first name is "Josef". (We have these problems
> ourselves with people from e.g. Japan ;-)
>
> > Thanks for the reply.iam an beginner in perl ..still not clear how to
> > convert the structure into an asciii string...i was stuck with this
> > issue for past 2 weeks..kindly throw some guidelines for this...
>
> As usual, TMTOWTDI:
>
> if you have the socket open, e.g. in $sock, just do
>
> *** Sender ***
> my $data =3D join(':', $a, @b, $c, $d, @e, @f);
> print $sock $data, "\n";
>
> *** Receiver ***
> my $data =3D <$sock>;
> chomp $data;
> my @data =3D split(/:/, $data);
> $a =3D $data[0];
> @b =3D @data[1..16];
> $c =3D $data[17];
> $d =3D $data[18];
> @e =3D @data[19..24];
> @f =3D @data[25..32];
>
> You could also use some kind of tagging:
>
> *** Sender ***
> print $sock "a=3D$a\n";
> foreach (0..15) {
>      print $sock "b$_=3D$b[$_]\n";}
>
> ...
> print $sock "\n";
>
> *** Receiver ***
>
> while (<$sock>) {
>      if (/^a=3D(\d+)/) {
>         $a =3D $1;
>      } elsif (/^b(\d+)?(\d+)/) {
>         $b[$1] =3D $2;
>      } ... {
>      } elsif (/^\s+$/) {
>         last;
>      }
>
> }
>
> Maybe XML could be used.
>
> You may also want to have a look at pack/unpack. They have data types
> which are pretty well defined (e.g. L is an unsigned long of exactly 32
> bits).
>
> It's all a matter of
> 1. what you feel comfortable to use
> 2. what is most stable
> 3. what is best maintainable
> 4. what is fast
> 5. what takes little space
>
> Obviously others will have more elegant solutions.
>
> Josef
> --
> These are my personal views and not those of Fujitsu Siemens Computers!
> Josef M=F6llers (Pinguinpfleger bei FSC)
>         If failure had no penalty success would not be a prize (T.  Pratc=
hett)
> Company Details:http://www.fujitsu-siemens.com/imprint.html- Hide quoted =
text -
>
> - Show quoted text -

hi josef,,

sorry for the mis interpretation of ur name....here my problem is i
cannot modify reciever code...reciever is a C code expecting data in
binary mode....so that is 1 of the reason i would like to do pack...i
saw that pack is used for sending binary data...i dont know how to
combine all the five elements in structure into a single variable
using pack command..

thanks & Regards
Rams



------------------------------

Date: Fri, 26 Oct 2007 01:56:20 -0700
From:  rams <haairam@gmail.com>
Subject: Re: packing a C structure
Message-Id: <1193388980.549980.164720@i38g2000prf.googlegroups.com>

On Oct 26, 1:18 pm, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
> rams wrote:
> > On Oct 26, 12:06 pm, Josef Moellers <josef.moell...@fujitsu-
> > siemens.com> wrote:
>
> >>haai...@gmail.com wrote:
>
> >>>hi ,,,
>
> >>>iam trying to pack a C structure to send via socket..i would like to
> >>>know how to frame the template for the C structure..
>
> >>>this is my structure
>
> >>>typedef struct buffer_t {
> >>>  uint32_t a;
> >>>  char b[16];
> >>>  uint32_t c;
> >>>  uint32_t d;
> >>>  char e[6];
> >>>  char f[8];
> >>>} buffer_t;
>
> >>>kindly suggest me the format for the pack function call..this will
> >>>help me to solve my issue...
>
> >>Transferring binary structures is inherently non-portable, so there is
> >>not a single way to deduce the actual binary layout of this structure,
> >>as the alignment and even the format of the binary numbers (e.g.
> >>endianness) will vary from machine type to machine type and even between
> >>compilers. It might even be impossible to transfer the data if the
> >>receiving machine is unable to handle 32 bit data, but I guess that's
> >>less of a problem.
> >>That's why techniques like ASN.1 were developed.
>
> >>If the amount of data is relatively small and you can live with some
> >>time spent in conversion, a simple (and more portable (*)) means to
> >>transfer this data is to transform it into ascii, with suitable
> >>separators, e.g. commas or colons, terminated by a line feed.
>
> >>(*) Sheesh, I sure hope Scott Nudds doesn't read this ;-) It's "more"
> >>portable because you have removed alignment and endianness problems,
> >>there's still a portability issue in that the receiving machine might
> >>speak EBCDIC while the sending machine speaks ASCII.
> >>--
> >>These are my personal views and not those of Fujitsu Siemens Computers!
> >>Josef M=F6llers (Pinguinpfleger bei FSC)
> >>        If failure had no penalty success would not be a prize (T.  Pra=
tchett)
> >>Company Details:http://www.fujitsu-siemens.com/imprint.html-Hide quoted=
 text -
>
> >>- Show quoted text -
>
> > hi Mollers,,
>
> No offence, but my first name is "Josef". (We have these problems
> ourselves with people from e.g. Japan ;-)
>
> > Thanks for the reply.iam an beginner in perl ..still not clear how to
> > convert the structure into an asciii string...i was stuck with this
> > issue for past 2 weeks..kindly throw some guidelines for this...
>
> As usual, TMTOWTDI:
>
> if you have the socket open, e.g. in $sock, just do
>
> *** Sender ***
> my $data =3D join(':', $a, @b, $c, $d, @e, @f);
> print $sock $data, "\n";
>
> *** Receiver ***
> my $data =3D <$sock>;
> chomp $data;
> my @data =3D split(/:/, $data);
> $a =3D $data[0];
> @b =3D @data[1..16];
> $c =3D $data[17];
> $d =3D $data[18];
> @e =3D @data[19..24];
> @f =3D @data[25..32];
>
> You could also use some kind of tagging:
>
> *** Sender ***
> print $sock "a=3D$a\n";
> foreach (0..15) {
>      print $sock "b$_=3D$b[$_]\n";}
>
> ...
> print $sock "\n";
>
> *** Receiver ***
>
> while (<$sock>) {
>      if (/^a=3D(\d+)/) {
>         $a =3D $1;
>      } elsif (/^b(\d+)?(\d+)/) {
>         $b[$1] =3D $2;
>      } ... {
>      } elsif (/^\s+$/) {
>         last;
>      }
>
> }
>
> Maybe XML could be used.
>
> You may also want to have a look at pack/unpack. They have data types
> which are pretty well defined (e.g. L is an unsigned long of exactly 32
> bits).
>
> It's all a matter of
> 1. what you feel comfortable to use
> 2. what is most stable
> 3. what is best maintainable
> 4. what is fast
> 5. what takes little space
>
> Obviously others will have more elegant solutions.
>
> Josef
> --
> These are my personal views and not those of Fujitsu Siemens Computers!
> Josef M=F6llers (Pinguinpfleger bei FSC)
>         If failure had no penalty success would not be a prize (T.  Pratc=
hett)
> Company Details:http://www.fujitsu-siemens.com/imprint.html- Hide quoted =
text -
>
> - Show quoted text -

hi josef,,

sorry for the mis interpretation of your name....
actually the problem for me is i will not be able to modify the
reciever part...and the reciever part is a C code interpreting data in
binary mode....so i saw that pack functionality is used to send data
in binary format...the problem is iam not able to combine all the
elements in the structure into a single variable using the pack
format.... L is for long and but how to combine all those elements?..

Thanks & regards
Rams



------------------------------

Date: Fri, 26 Oct 2007 11:29:00 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: packing a C structure
Message-Id: <ffsc16$673$1@nntp.fujitsu-siemens.com>

rams wrote:
> On Oct 26, 1:18 pm, Josef Moellers <josef.moell...@fujitsu-
> siemens.com> wrote:
>=20
>>rams wrote:
>>
>>>On Oct 26, 12:06 pm, Josef Moellers <josef.moell...@fujitsu-
>>>siemens.com> wrote:
>>
>>>>haai...@gmail.com wrote:
>>
>>>>>hi ,,,
>>
>>>>>iam trying to pack a C structure to send via socket..i would like to=

>>>>>know how to frame the template for the C structure..
>>
>>>>>this is my structure
>>
>>>>>typedef struct buffer_t {
>>>>> uint32_t a;
>>>>> char b[16];
>>>>> uint32_t c;
>>>>> uint32_t d;
>>>>> char e[6];
>>>>> char f[8];
>>>>>} buffer_t;
>>
>>>>>kindly suggest me the format for the pack function call..this will
>>>>>help me to solve my issue...
>>
>>>>Transferring binary structures is inherently non-portable, so there i=
s
>>>>not a single way to deduce the actual binary layout of this structure=
,
>>>>as the alignment and even the format of the binary numbers (e.g.
>>>>endianness) will vary from machine type to machine type and even betw=
een
>>>>compilers. It might even be impossible to transfer the data if the
>>>>receiving machine is unable to handle 32 bit data, but I guess that's=

>>>>less of a problem.
>>>>That's why techniques like ASN.1 were developed.
>>
>>>>If the amount of data is relatively small and you can live with some
>>>>time spent in conversion, a simple (and more portable (*)) means to
>>>>transfer this data is to transform it into ascii, with suitable
>>>>separators, e.g. commas or colons, terminated by a line feed.
>>
>>>>(*) Sheesh, I sure hope Scott Nudds doesn't read this ;-) It's "more"=

>>>>portable because you have removed alignment and endianness problems,
>>>>there's still a portability issue in that the receiving machine might=

>>>>speak EBCDIC while the sending machine speaks ASCII.
>>>>--
>>>>These are my personal views and not those of Fujitsu Siemens Computer=
s!
>>>>Josef M=F6llers (Pinguinpfleger bei FSC)
>>>>       If failure had no penalty success would not be a prize (T.  Pr=
atchett)
>>>>Company Details:http://www.fujitsu-siemens.com/imprint.html-Hide quot=
ed text -
>>
>>>>- Show quoted text -
>>
>>>hi Mollers,,
>>
>>No offence, but my first name is "Josef". (We have these problems
>>ourselves with people from e.g. Japan ;-)
>>
>>
>>>Thanks for the reply.iam an beginner in perl ..still not clear how to
>>>convert the structure into an asciii string...i was stuck with this
>>>issue for past 2 weeks..kindly throw some guidelines for this...
>>
>>As usual, TMTOWTDI:
>>
>>if you have the socket open, e.g. in $sock, just do
>>
>>*** Sender ***
>>my $data =3D join(':', $a, @b, $c, $d, @e, @f);
>>print $sock $data, "\n";
>>
>>*** Receiver ***
>>my $data =3D <$sock>;
>>chomp $data;
>>my @data =3D split(/:/, $data);
>>$a =3D $data[0];
>>@b =3D @data[1..16];
>>$c =3D $data[17];
>>$d =3D $data[18];
>>@e =3D @data[19..24];
>>@f =3D @data[25..32];
>>
>>You could also use some kind of tagging:
>>
>>*** Sender ***
>>print $sock "a=3D$a\n";
>>foreach (0..15) {
>>     print $sock "b$_=3D$b[$_]\n";}
>>
>>...
>>print $sock "\n";
>>
>>*** Receiver ***
>>
>>while (<$sock>) {
>>     if (/^a=3D(\d+)/) {
>>        $a =3D $1;
>>     } elsif (/^b(\d+)?(\d+)/) {
>>        $b[$1] =3D $2;
>>     } ... {
>>     } elsif (/^\s+$/) {
>>        last;
>>     }
>>
>>}
>>
>>Maybe XML could be used.
>>
>>You may also want to have a look at pack/unpack. They have data types
>>which are pretty well defined (e.g. L is an unsigned long of exactly 32=

>>bits).
>>
>>It's all a matter of
>>1. what you feel comfortable to use
>>2. what is most stable
>>3. what is best maintainable
>>4. what is fast
>>5. what takes little space
>>
>>Obviously others will have more elegant solutions.
>>
>>Josef
>>--
>>These are my personal views and not those of Fujitsu Siemens Computers!=

>>Josef M=F6llers (Pinguinpfleger bei FSC)
>>        If failure had no penalty success would not be a prize (T.  Pra=
tchett)
>>Company Details:http://www.fujitsu-siemens.com/imprint.html- Hide quote=
d text -
>>
>>- Show quoted text -
>=20
>=20
> hi josef,,
>=20
> sorry for the mis interpretation of ur name

No problem, as I said. (BTW it's "your", "ur" is kiddie-talk)

=2E...here my problem is i
> cannot modify reciever code...reciever is a C code expecting data in
> binary mode....so that is 1 of the reason i would like to do pack...i
> saw that pack is used for sending binary data...i dont know how to
> combine all the five elements in structure into a single variable
> using pack command..

Ah, OK, I see. Then "pack" is your friend.
But, as I have written, you have to find out the receiving side's=20
endianness and alignment restrictions.
Usually data items have to be aligned on boundaries that are a multiple=20
of their own size, but since b is 16 bytes (which is a multiple of 4,=20
c's size), and e and f are char arrays, the following should do:

# make sure @b is of the correct size
die "Bad size of \@b\n" unless @b =3D=3D 16;
# same for @e and @f ...
print $sock pack('LC16LLC6C8', $a, @b, $c, $d, @e, @f);

Note that you could combine 'LL' into 'L2' and 'C6C8' into 'C14', but I=20
find this more descriptive.

HTH,
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html



------------------------------

Date: Thu, 25 Oct 2007 18:18:47 -0700
From:  hendedav@gmail.com
Subject: Re: PID of exec
Message-Id: <1193361527.628332.224820@19g2000hsx.googlegroups.com>

On Oct 25, 7:49 pm, an...@alumni.caltech.edu (Gary E. Ansok) wrote:
> In article <1193352439.621195.249...@22g2000hsm.googlegroups.com>, <hende...@gmail.com> wrote:
>
> [much snippage]
>
> >That seemed to have worked.  Here is the adjusted code:
>
> >} else {
> >   $|++;
> >   open STDOUT, '>', '/dev/null';
> >   open STDIN, '>', '/dev/null';
> >   open STDERR, '>', '/dev/null';
> >   exec("/tmp/test.sh");
> >   exit();
> >}
>
> STDIN should be opened with '<' rather than '>'.  This won't matter
> unless /tmp/test.sh or something it calls tries to read from standard
> input, but if it does, better to get end-of-file instead of a
> runtime error.
>
> Gar


Thanks Gary.  Is the STDERR pointed the correct way?  Also, this
script seems to be generating zombies.  Anyone have ideas on how to
clear that up?  I was hoping that the "local $SIG{CHLD} = "IGNORE";"
line would do the trick (as it stated in the perldoc's), but I guess
not.

Thanks,
Dave



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 977
**************************************


home help back first fref pref prev next nref lref last post