aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes how to exchange binary data between applet and server socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how to exchange binary data between applet and server socket" Watch "how to exchange binary data between applet and server socket" New topic
Author

how to exchange binary data between applet and server socket

Dorj Galaa
Ranch Hand

Joined: May 29, 2001
Posts: 113
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

Senior software engineer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to exchange binary data between applet and server socket