Java two- way socket connection (server/ client)
===

what I'm trying to do is to send some JSON from an Android phone to a Java server, which works fine. The Android/ client side looks like this: 

    					Socket s = new Socket("192.168.0.36", 12390);
					s.setSoTimeout(1500);
					
					JSONObject json = new JSONObject();
					json.put("emergency", false);
					json.put("imei", imei);
					json.put("lat", l.getLatitude());
					json.put("lon", l.getLongitude());
					json.put("acc", l.getAccuracy());
					json.put("time", l.getTime());
					

					BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
							s.getOutputStream()));
					out.write(json.toString());
					out.flush();
					s.close();


The server side is this: 

    	    try {
	        s = new ServerSocket(port);
	    } 
	    catch (IOException e) {
	        System.out.println("Could not listen on port: " + port);
	        System.exit(-1);
	    }
	    
	    
	    Socket c = null;
	    while (true) {
			try {
				c = s.accept();
			} catch (IOException e) {
				System.out.println("Accept failed: " + port);
				System.exit(-1);
			}
			try {
				
				BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
    				String inputLine = null;
				String result = "";
				while ((inputLine = in.readLine()) != null) {
					result = result.concat(inputLine);	
				}
				System.out.println(result);

As I said, all of that works. Now I want to send a message back from the server to the client after it received the message from the client. 
I extended the code like this, Android/ client side: 

    					Socket s = new Socket("192.168.0.36", 12390);
					s.setSoTimeout(1500);
					
					JSONObject json = new JSONObject();
					json.put("emergency", false);
					json.put("imei", imei);
					json.put("lat", l.getLatitude());
					json.put("lon", l.getLongitude());
					json.put("acc", l.getAccuracy());
					json.put("time", l.getTime());
					

					BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
							s.getOutputStream()));
					out.write(json.toString());
					out.flush();
					
					String inputLine = null;
					String result = "";
					BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));	
					while ((inputLine = in.readLine()) != null) {
						Log.d(TAG, in.readLine());
						result = result.concat(inputLine);
					}

And  the server side: 

            try {
        s = new ServerSocket(port);
    } 
    catch (IOException e) {
        System.out.println("Could not listen on port: " + port);
        System.exit(-1);
    }


    Socket c = null;
    while (true) {
        try {
            c = s.accept();
        } catch (IOException e) {
            System.out.println("Accept failed: " + port);
            System.exit(-1);
        }
        try {

            BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
                String inputLine = null;
            String result = "";
            while ((inputLine = in.readLine()) != null) {
                result = result.concat(inputLine);  
            }
            System.out.println(result);

		PrintWriter out = new PrintWriter(c.getOutputStream());
		out.write("Hello phone");
		out.flush();
		out.close();

On the client side, nothing ever comes in, it hangs on 

                    while ((inputLine = in.readLine()) != null) {
                    Log.d(TAG, in.readLine());
                    result = result.concat(inputLine);
                }

until the socket times out (never enters the loop). I thought it might be a timing problem, for example the server sending out its reply too early and therefore the client never receiving anything, but i tried to put the out.write("Hello phone"); pretty much anywhere in the code, always the same result. Can it have to do with the socket being obtained from ServerSocket and not being able to send out data? What am I missing here, this is bugging me all day ... 