This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
Don't get me started about those stupid light bulbs.
 
subject: how to exchange binary data between applet and server socket
 
Similar Threads
Client-Server Problem
Random EOFException - runs for minutes, hours or days and then suddenly throws this (sometimes)
Client-Server communication; client freezes
how to read binary data from socket
Help me Socket