Differences

This shows you the differences between two versions of the page.

Link to this comparison view

public:howto:udpserver [2007/11/30 14:30] (current)
Line 1: Line 1:
 +====== How To Write A UDP Server? ======
  
 +
 +Try next code on thread, or in any other case:
 +
 +<code delphi>
 +procedure TSomeThread.Execute;
 +var
 +  Sock:TUDPBlockSocket;
 +  size:integer;
 +  buf:string;
 +begin
 +  Sock:=TUDPBlockSocket.Create;
 +  try
 +    sock.bind('0.0.0.0','port');
 +    if sock.LastError0 then exit;
 +    while True do
 +      begin
 +        if terminated then break;
 + buf := sock.RecvPacket(1000);
 + if sock.lasterror=0 then
 +   begin
 +  //        do something with data and prepare response data
 +            sock.SendString(Buf);
 +          end;
 +        sleep(1);
 +      end;
 +    sock.CloseSocket;
 +  finally
 +    sock.free;
 +  end;
 +end;
 +</code>
public/howto/udpserver.txt · Last modified: 2007/11/30 14:30 (external edit)
Driven by DokuWiki Recent changes RSS feed