Trying to understand the data flow in Java
hi, I have been working on a project using s scheme client-server, I already create my class "server" and my class "client". I have these three lines: 1) Socket s=new Socket("127.0.0.1",5432); 2) ObjectInputStream in=new ObjectInputStream(s.getInputStream()); 3) ObjectOutStream out=new ObjectOutputStream(s.getOutputStream()); The rare thing starts when the compiler gets to the second line and the program gets stuck, it doesn't carry on. BUT when I change the order like this: 1) Socket s=new Socket("127.0.0.1",5432); 2) ObjectOutStream out=new ObjectOutputStream(s.getOutputStream()); 3) ObjectInputStream in=new ObjectInputStream(s.getInputStream()); The program continues executing and does what it has to do SO my question is: why is important to write the output first and then the input? otherwise, it will get stuck