Sorry, I couldn’t resist. I’ve been testing receiving data through the socket server I talked about in my last post. If you are testing without a steady stream of incoming data, you may need to generate your own UDP packets to send to your socket server. Here’s a simple script to open the socket on the other end. Keep in mind there is no back and forth communication with the User Datagram Protocol (UDP).
Create the socket, see the PHP documentation on which settings to use, these are for a UDP connection.
#!/usr/bin/php -q
<?php
/* create a socket in the AF_INET family,
using SOCK_DGRAM for udp connections */
$mysock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
Specify your host and port, and put together a packet string to send:
Filed by joshc at March 14th, 2008 under
programming |
No comments