Creating a C struct in Perl

Discussion in 'OT Technology' started by dinger, Feb 12, 2005.

  1. dinger

    dinger Guest

    I have a server program written in C (whose source code I do not have access to) which listens to incoming connections over a UDP socket, and receives messages and casts them to a specific struct and then pulls out the values.


    struct packet {
    unsigned int type;
    unsigned int SeqNum;
    unsigned int length;
    char data[500];
    }


    I want to write a client program in Perl that sends messages to this thing. How do I know what byte order to use when constructing my message so that it gets interpreted correctly on the other side?

    Thanks!
     
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    You shouldn't have to worry about byte order at the other end. A TCP/IP network has it's own byte order, and any software written for platforms that have byte order that's opposite of network byte order has to convert data written or read over the network appropriately. So your server and client only need to worry about host to network conversion and vice-versa if necessary.
     
  3. dinger

    dinger Guest

    Thanks. Without regards byte order though, how do I send a message in Perl that can be interpreted as a struct in C?
     
  4. zabuni

    zabuni New Member

    Joined:
    Jan 2, 2005
    Messages:
    64
    Likes Received:
    0

Share This Page