Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><br>Dont use reader/writer some times i cause problem such as we cannOt predict end of string,etc.So please write or read only byte or byte array.It is the better way. <br>The following are the sample coding snippet</p> <pre><code> socket=new Socket(this.ipAddress,this.port_number); //socket.setSocketImplFactory(fac) Log.i(tagName, "after creating sokcet"); os=socket.getOutputStream(); is=socket.getInputStream(); dos=new DataOutputStream(os); Log.i(tagName, "after creating ouput streams"); dis=new DataInputStream(is); Log.i(tagName, "after creating input streams"); //dos.writeUTF(msg[i].trim()); //dos.write(msg[i].trim().getBytes()); //dos.writeUTF(msg[i].trim()); dos.write(msg[i].trim().getBytes()); //dos.writeUTF(str) dos.flush(); Log.i(tagName, "after writing data to os"); StringBuilder sbuilder=new StringBuilder(); ///* int ch; byte bt=1; while((bt=(byte) dis.read())!=-1) { Log.i(tagName, "ch="+bt); byte temp[]=new byte[1]; //temp[0]=(byte)ch; temp[0]=(byte)bt; String tempStr1=new String(temp); Log.i(tagName, "tempstr:"+tempStr1); sbuilder.append(tempStr1); Log.i(tagName, "Data fro server : "+sbuilder.toString()); tempStr1=null; } //*/ //byte tt[]=new byte[dis.readLine()] //resultStr=dis.readLine();resultStr=resultStr.trim(); resultStr=sbuilder.toString(); Log.i(tagName, "server res :"+resultStr); (Toast.makeText(this.actitivity,"Result : "+resultStr,Toast.LENGTH_SHORT)).show(); if(dos!=null) { try { dos.close(); } catch(Exception ex) { } } if(dis!=null) { try { dis.close(); } catch(Exception ex){} } if(socket!=null) { try { socket.close(); } catch(Exception ex) { } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload