java - EOFException in readUTF -


i getting below eofexception while using readutf() method, please let me know how overcome problem , please suggest how readutf() transfers socket information on other networks

import java.io.*; import java.net.*;  public class greetingserver {     public static void main(string args[]) {         string servername =args[0];         int port = integer.parseint(args[1]);          try {             system.out.println("server name "+ servername +"port"+port);              socket client = new socket(servername,port);             system.out.println("just connected to"+ client.getremotesocketaddress());             outputstream outs = client.getoutputstream();             dataoutputstream dout = new dataoutputstream(outs);             dout.writeutf("hello from"+client.getremotesocketaddress());             inputstream in = client.getinputstream();             datainputstream din = new datainputstream(in);             system.out.println("server says"+ din.readutf());             client.close();         }         catch (eofexception f) {             f.printstacktrace();         }         catch(ioexception e) {             e.printstacktrace();         }     } } 

you have reached end of stream. there no more data read.

possibly server isn't using writeutf(), or out of sync it. if server writing lines should using bufferedreader.readline().


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -