screative wrote:I am a complete beginner when it comes to udp.. I understand that it differs from TCP in that you don't get a confirmation the packet was delivered.. but that is about it.
Wrong. TCP doesn't give you a confirmation either, but it will transparently retry if an error occurs, up to some timeout.
TCP however, does not work in packets, it works in streams; that's to say, lumps of data you send may be joined together or split up as necessary by the underlying implementation.
UDP does not do this; it preserves message boundaries.
Basicly whatn I need to do is have php connect to my ip address (10.0.0.4) and send the message '3422' to the ip address.
UDP has no notion of what a "connection" is, you simply send messages and hope they get there (unless you protocol has some built-in acknowledgement mechanism, in which case you must implement it correctly).
Maybe.
The easiest way and most modern way in PHP is using fsockopen - this will always be available and will support UDP if the OS supports it (which is basically always):
$sock = fsockopen("udp://wherever", $port_number, $errno, $errstr);
$res = fwrite($sock, $some_binary_data); // Sends a UDP message
I consider the socket_ functions deprecated.
Mark