Sending data using UDP

Discussion in 'PHP' started by larenge, Dec 27, 2011.

  1. #1
    I want to send the following data using UDP.


    $packet[0] = 0x01;
    $packet[1] = 0x11;
    $packet[2] = 0xF1;
    $packet[3] = 0xD1;
    $packet[4] = 0xF1;
    $packet[5] = 0xB1;
    $packet[6] = 0xC1;
    $packet[7] = 0xF1;


    I used int socket_sendto ( resource $socket , string $buf , int $len , int $flags , string $addr [, int $port = 0 ] ) function to send.


    But it accepts a string.How can i convert interger array and send data to UDP server, So that data is treated as 1 byte each.


    Thanks.
     
    larenge, Dec 27, 2011 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    loop the array? or add all packets to a string and give each array item a EOF! or something.
     
    EricBruggema, Dec 29, 2011 IP