Java Socket Programming.
Posted on 2004-09-22
I have the following problem:
1) I have a client.
2) I have a proxy server which basically relays messages between a real server and the client.
3) The proxy server when requested by the client can connect to say port 21(ftp) on the real server .
My problem is....i have connected the proxy server to the real server and the client is connected to the proxy server.....however when i try to send the messages from the proxy server to the client i am not getting all the messages sometimes i am getting only half the message some times i am getting the entire message and so on...i tried flushing to the stream but to no effect.
The following is part of my client and server code
DataOutputStream outToServer = new
DataInputStream inFromServer = new DataInputStream(clientSocket.getInputStream());
byte ins = new byte; // i think this is creating a problem is there any way to know how many bytes the server is sending so that
// we can allocate that much to the byte array????
mod = new String(ins);
outToServer.writeBytes(sentenceToSend + "\n");
Server.java basically does the same thing while writing to the client.
I have tried using both readfully and read in java.io.BufferedReader .
Please kindly help.
This is urgent.
Thanks a lot