I have a problem with sockets.
I am using this code in java as the client:

class Javaclient {

    private static DataInputStream input;
    private static PrintStream output;

    public static void main(String argv[]) throws Exception {
        int PortNumber = 4321;
        String line;
        BufferedReader in;
        Socket MyClient = null;
        try {
            MyClient = new Socket("localhost", PortNumber);
        } catch (IOException e) {
        in = new BufferedReader(new InputStreamReader(MyClient.getInputStream()));
        line = in.readLine();
        System.out.println("data " + line);

I am sending from the socket server(in c) data to this java client.
My problem is, that in Java my data is not printed until I stop the c server.
So when I do stop it it prints everything i have been sending.
This is my c code after getting a connection:

while (1) {
            printf("\n SEND : ");
            send(connected, send_data, strlen(send_data), 0);


    return 0;

Can someone help me on how I can get the data immediately after sending, and without stopping the c server?

The readLine() method is for reading lines. A line ends with an line end character.
The readLine method will continue reading until it gets a lineend.

Some solutions:
Use the read method and read the data into an array as it comes
or have the sender add line end characters

Fast and clear answer

Adding the endline did the trick.

This question has already been answered. Start a new discussion instead.