neodymium has asked for the wisdom of the Perl Monks concerning the following question:

There is a server written in C that sends 5 integers to any client who connects....how would i go about writting a client in perl which (after connecting) reads these ints and outputs the actual decimals???

Replies are listed 'Best First'.
Re: Client writing
by traveler (Parson) on Oct 19, 2001 at 23:01 UTC
    Before designing your program you will need to answer some questions:
    • Is the server TCP or UDP?
    • Are the data sent as ascii or binary integers?
    • If the data are binary, are they in Network Byte Order?
    • Are the data 16 bit, 32bit or 64bit integers?
    Each of these questions will have an impact on your design. You'll need a different type of client for TCP vs. UDP. You'll need to unpack binary numbers. You'll need to unpack binary numbers with a or A depending on length if the numbers are in NBO.

    HTH, --traveler

      Is the server TCP or UDP?
      > the data will be TCP SOCK-STREAM

      Are the data sent as ascii or binary integers?
      > the data will be binary integers

      Network Byte Order?
      > the ints will be recieved in NBO must be multiplied
      > together and then the answer sent back in NBO

      16, 32, or 64 integers?
      > ummm.....eheh i don't know would it make a difference?
Re: Client writing
by broquaint (Abbot) on Oct 19, 2001 at 22:01 UTC
    If you want to write a simple TCP client then the IO::Socket modules may be the thing for you, they deal with most of the fiddly coding that comes with this sort of thing. As for retrieving those ints I get the feeling that unpack() will be the function of choice, as it works a treat on binary data.
    HTH

    broquaint

Re: Client writing
by jackdied (Monk) on Oct 19, 2001 at 22:08 UTC
    'man perlipc'

    Update : To those who modded this down, is a two word reply really insufficient for a one sentance question? (also, man perlipc contains full source for a TCP client/server).