This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
how to exchange binary data between applet and server socket
posted 14 years ago
This is the serversocket code for read and write binary data from applet. DataOutputStream out =new DataOutputStream(socket.getOutputStream()); BufferedReader br= new BufferedReader(new InputStreamReader(socket.getInputStream())); String ss=br.readLine(); br.close(); String FileName="data/"+ss+".dat"; DataInputStream datainputstream = new DataInputStream(new FileInputStream(FileName)); datainputstream.skipBytes(10); datainputstream.read(points,0,126); datainputstream.close(); out.write(points,0,126); out.println(T); out.close(); // this is for connection to Serversocket and get the binary data from serversocket Socket socket=new Socket("192.168.0.71",port); PrintStream out= new PrintStream(socket.getOutputStream()); out.println(filename); out.flush(); out.close(); byte p01=new byte; DataInputStream in=new DataInputStream(socket.getInputStream()); in.read(p01,0,300); in.close(); socket.close(); ServerSocket can read request from applet, but cannot send binary data to applet. Maybe some mistakes in my code, please check them. If you have examples related with my situation send to me. Sincerely