A question about UDP packet receive
- From: Reeze <reeze.xia@xxxxxxxxx>
- Date: Wed, 29 Oct 2008 19:10:58 -0700 (PDT)
Hi, everyone.
I need your help!
I created a UDP server by using $socket =
stream_socket_server($udpAddr, $errno, $errstr, STREAM_SERVER_BIND);
the client send me a reqest, then server return a "hello string".
but the client simply send me a name or something very short. I have
to read upto 100 chars, then the fread can return.
my Question is: how can I read a udp packet which length is unknow?
thank a lot!
Reeze.
my src code:=====================================
$pkt = stream_socket_recvfrom($socket, 100, 0, $peer);
$reciv_data = fread($socket, 100);
$message = preg_replace("/[[:space:]]/", '', $reciv_data); // cleanup
data
$response = "hello, $message";
stream_socket_sendto($socket, $response, 0, $peer);
echo " In > [$message] \n";
echo " Out > [$response] \n";
.
- Follow-Ups:
- Re: A question about UDP packet receive
- From: Tim Roberts
- Re: A question about UDP packet receive
- Prev by Date: Re: bollhy"system" function output displays twice last line
- Next by Date: Re: Check if a certain service is running on the server
- Previous by thread: Run a SQL query based on HTML drop down selection?
- Next by thread: Re: A question about UDP packet receive
- Index(es):
Relevant Pages
|