Java Socket Problem
Hi,
I have got a problem with sending information through a Java socket to a Python Sever... For some reason the string variable that I said through which is a discID never gets sent.
I know the server is not the problem because I create a Python Client to test it...
Both The sever and client are running on local host and they bind with each other, I have checked this by doing the clientSocket.getConnected method and it returns true.
If you could help me out it would be really helpful.
Thanks
Here the code:
publicclass ServerConnection
{
private String serverAddress ="127.0.0.1";
privateint serverPort = 5555;
private Socket clientSocket =null;
private PrintWriter informationOut =null;
private BufferedReader informationIn =null;
private String unFormattedInfo;
private String discHash;
public ServerConnection(){
discHash = DiscInfo.findCdInformation();
serverConnect();
}
publicvoid serverConnect()
{
try{
System.out.println("Connecting To Server...");
clientSocket =new Socket(serverAddress, serverPort);
informationOut =new PrintWriter(clientSocket.getOutputStream(),true);
informationIn =new BufferedReader(new InputStreamReader(clientSocket
.getInputStream()));
}
catch (UnknownHostException e){
System.err.println("Don't Know Host: " + clientSocket.getInetAddress());
System.exit(1);
}
catch (IOException e){
System.err.println("I/O Error While Connecting To Host: ");
System.exit(1);
}
BufferedReader bufferInput =new BufferedReader(new InputStreamReader(
System.in));
try{
while ((discHash = bufferInput.readLine()) !=null){
informationOut.println(discHash);
unFormattedInfo = informationIn.readLine();
}
informationOut.close();
informationIn.close();
bufferInput.close();
clientSocket.close();
}
catch (IOException error){
// TODO Auto-generated catch block
error.printStackTrace();
}
}
/**
* @return This serverConnection's unFormattedInfo
*/
public String getUnFormattedInfo(){
return unFormattedInfo;
}
}

