Socket Reading Error
I had a basic server and client set up: a server in c and client in python. The client would take in input and send it to the server. When the server recieved data from the client, it would echo it back to the client.
I decided to move the client into Java: now everything works except recieving messages from the server. When it gets to System.exit(0), it suddenly prints out all the messages in a clump and exits with an error. The error isn't as much of a problem as the whole clump thing, though:
la
laa
laaaa
quit
Cleaning up... done.
Good-bye!
Server said: lalaalaaaa
Exception in thread"Thread-0" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:817)
at java.util.Scanner.next(Scanner.java:1317)
My code for initializing the Scanner:
socketIn =new Scanner(System.in);
try{
socketIn =new Scanner(clientSock.getInputStream());
}
catch (IOException e)
{ System.out.println("There was an error initializing the input stream. You will be able to send messages, but not recieve them.");
}
The code for reading from the socket inputstream:
new Thread(new SocketReadThread()).start();
...
privateclass SocketReadThreadimplements Runnable
{
publicvoid run()
{
String s ="";
while((s = socketIn.next()) !=null)
System.out.println("Server said: " + s);
}
}
Please help me!
Thanks,
Andy

