A question about UDP packet receive



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";
.



Relevant Pages

  • Re: Zero Byte Terminated Strings
    ... I'm writting a simple UDP server in Java, ... initial request packet from a C based client and perform further ... extracting the string information. ...
    (comp.lang.java.programmer)
  • Previously Functioning Date Interpreter Now Failing
    ... Dim Entry As String ... Dim Result As String ... Dim ClientElement As Variant 'Holds the extracted Client Number ... ElseIf IsNumeric= False _ ...
    (microsoft.public.excel.programming)
  • RE: Previously Functioning Date Interpreter Now Failing
    ... Dim Entry As String ... Dim Result As String ... Dim ClientElement As Variant 'Holds the extracted Client Number ... ElseIf IsNumeric= False _ ...
    (microsoft.public.excel.programming)
  • Re: Threading a server
    ... I am getting myself into a really big hole with this and the client is a little upset. ... private TcpListener tcpListener; ... private string CurrentCommand ... public string ExpectedSubject ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: SoapHttpClientProtocol request canceled
    ... Since this is only happening on the VB client, is there any chance that the ... The VB.NET exe and the VB6 exe both use VB.NET dll to sent request/response ... > inputHeaderer, String messageControlPayload, string inputMessage) ... > Imports System.ComponentModel ...
    (microsoft.public.dotnet.framework.webservices)