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) {
System.out.println(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 : ");
gets(send_data);
send(connected, send_data, strlen(send_data), 0);
fflush(stdout);
}
close(sock);
return 0;
Can someone help me on how I can get the data immediately after sending, and without stopping the c server?