title: Delphi xe-3 indy 10 unable to read data tidudpserver onudpread
body: <p>i am using tidudpserver for both client and server .below is the server and client code given.    </p>
  
  <pre><code>unit udp_server;
  
  
  
  procedure TForm4.serverUDPRead(AThread: TIdUDPListenerThread;
    AData: array of Byte; ABinding: TIdSocketHandle);
  var
    buffer:tbytes;
    buffer2:tbytes;
    i:integer;
    ex_port:word;
    i_ip,ex_ip:string;
    t: string;
  begin
     ex_ip:=abinding.PeerIP;      //public_ip
     ex_port:=abinding.PeerPort;   //public_port
  
     //byte  to string
     setlength(i_ip,length(adata) div 2);  
  
     // extract private ip from array of byte
     move(Adata[0],i_ip[1],length(adata)); 
  
     // client profile  {object of tclient }
     user:=tclient.create(ex_ip,ex_port,i_ip,0,''); 
     //copying public and private    endpoints to tclient object
  
  
     setlength(buffer,sizeof(user));         
     move(user,buffer[0],sizeof(user)); // copying object to byte array 
  
  
     server.Sendbuffer(abinding.PeerIP,abinding.PeerPort,buffer); 
     // send client info to all connected clients(is this correct way of sending buffer(byte array)?)
  end;
  </code></pre>
  
  <p>This is the clients code given .i am unable to read data sent by the server in <code>onudpread</code> procedure. How can i convert the byte array (which contains strings and word types) to readable text? </p>
  
  <pre><code>unit udp_client;
  
  
  
  procedure TForm4.server2UDPRead(AThread: TIdUDPListenerThread;
    AData: array of Byte; ABinding: TIdSocketHandle);
  var
    dest:string;
    user2:tclient;// i had a tclient class in a separate file
    buffer:tbytes;
  begin
  
  
    setlength(dest,length(adata));
    move(Adata[0],dest[1],length(adata));  // problem is over here ,is this correct?
  end;
  </code></pre>
  
  <p>private ip sent from the client </p>
  
  <pre><code>              ip:=getipaddress; //call private ip function taken from (http://delphi.about.com/od/networking/l/aa103100a.htm)
  
                setlength(i_ip,length(ip)*2);
  
                move(ip[1],i_ip[0],length(i_ip));
  
                server2.Sendbuffer('host',port,i_ip); 
  </code></pre>
  
  <p>i want to do udp hole punching for that clients need to send their info(public/private ip/port) to server and then server will exchange clients info and then they should be able chat.i am confused as adata array is receiving all data would the ip's and text message get mix with each other?currently i am receiving garbage value, its like chinese.:-/</p>