php udp

Sekcia: Programovanie 08.07.2010 | 17:27
Nickname   Návštevník
Zdravim, mam problem tykajuci sa prijimania packetov cez UDP... v zivote som s UDP nepracoval precital som par tutorialov tykajucich sa UDP a podpory PHPcka.. potrebujem vytvort skript ktory bezi neustale a pri prijati packetu ho savne do filu... avsak moj vytvor hodi chybu vzdy ked pride packet:

Warning: socket_read() expects parameter 1 to be resource, boolean given in ... on line 15
PHP Warning: socket_accept(): unable to accept incoming connection [0]: The attempted operation is not supported for the type of object referenced in ... on line 14

kod:

<?php
set_time_limit (0);
$host = "0.0.0.0"; //IP hostu
$i=0;
$ink = 0;
$port = 9000;
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$bind = socket_bind($socket, $host, $port);
socket_recvfrom($socket, $buf, 12, 0, $host, $port);
$listen = socket_listen($socket, 0);
$f = fopen("text.txt","w");
while(true)
{
$spojenie = socket_accept($socket);
$read = socket_read($spojenie, 20480);
$add = $read."\n";
fwrite($f,$add);
//socket_close($spojenie);
}
?>
    • Re: php udp 08.07.2010 | 20:20
      Avatar Dare_devil Debian, OpenSuse  Používateľ
      Podla netu by si mal zmazat premennu $listen a socket_read pouzit s parametrom $socket miesto $spojenie..

      Zdroj: http://www.phpbuilder.com/board/showthread.php?t=10360422
      Keby daco ozvi sa mi cez jabber / gtalk, kontakt na mna mas .. :)
      There is no flag large enough to cover the shame of killing innocent people