Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to exchange binary data between applet and server socket

 
Dorj Galaa
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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[300];
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic