Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
i am having a strange problem.i have written a code in socket programming wherein client sends a string to server and server sends back the string converting it to uppercase.the problem is when i run the code and start giving input the program works fine for first 7-8 lines and after that for the next 8-10 line of input no o/p is displayed immediately.the o/p appears together after 10 lines and again everything is all right for the next 8 lines.this cycle continues till i end the program.what is wrong with the code?
public static void main(String argv[]) throws Exception BufferedReader inFromUser = Socket clientSocket = new Socket("hostname", 6789); DataOutputStream outToServer = BufferedReader inFromServer = outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println(modifiedSentence); clientSocket.close(); }
import java.io.*; class TCPServer { public static void main(String argv[]) throws Exception ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = DataOutputStream outToClient = capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); Replies:
|
Sponsored Links
|