Hi!
I'm trying to send a text file over a socket, from client to server, but I doesn't work. I will demonstrate a part of the code that isn't working.
The critical part of the server look like this:
while(true) { try { Socket socket = fileSocket.accept(); out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String s = in.readLine();
And the client like this:
Socket = new Socket(address, number); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Socket.getOutputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(Socket.getInputStream())); BufferedReader fileIn = new BufferedReader(new FileReader(filename)); String s = fileIn.readLine(); out.write(s);
Now I want the s in the server to hold the same string as s in the client, but the server can't read the stream - nothing happes.
I know that readLine() reads until a new line character, but it doesn't word to write and read a single character either.
Hank