You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Octav Chipara <oc...@cse.unl.edu> on 2000/05/10 19:44:25 UTC
Java Help
Hi,
I hope that among you there are some Java genius able to help me. I am
trying to make a client and a have big problem in Java not waiting for the
for the server to end its message. Do you have any idea how can I get
around this problem. Any ideas and suggestions are more then welcomed.
Thanks,
Octav
PS: My code is:
import java.net.*;
import java.io.*;
public class Client1_0 {
//Main method
public static void main(String[] args) throws IOException
{
Socket NewSocket=null;
PrintWriter out=null;
BufferedInputStream in=null;
//String HostName="cse-mfayad2.unl.edu";
String HostName="cse.unl.edu";
DataInputStream stdin= new DataInputStream(System.in);
try
{
System.out.println("Starting to tests...");
NewSocket=new Socket(HostName,21);
out= new PrintWriter(NewSocket.getOutputStream(),true);
in = new BufferedInputStream(NewSocket.getInputStream(), 1000);
} catch (UnknownHostException e){
System.err.println("Unknown host ("+HostName+")");
System.exit(-1);
} catch (IOException e) {
System.err.println("Could not get IO access to "+HostName);
System.exit(-1);
};
System.out.println("Connection to "+HostName+" established");
byte i;
String UI;
int j;
int size=0;
while (size==0) size=in.available();
for (j=0;j<size;j++) System.out.print((char)in.read());
while (true)
{
UI=stdin.readLine();
out.println(UI);
try
{
in.wait();
size=0;
while (size==0) size=in.available();
size=in.available();
System.out.println("****"+size);
for (j=0;j<size;j++) System.out.print((char)in.read());
} catch (
} catch (EOFException e) {
System.err.println("OK");
} catch (IOException e) {
System.err.println("OK");
};
};
};
};
Re: Java Help
Posted by Mike Pogue <mp...@apache.org>.
Does this have anything to do with XML?
Mike
Octav Chipara wrote:
>
> Hi,
>
> I hope that among you there are some Java genius able to help me. I am
> trying to make a client and a have big problem in Java not waiting for the
> for the server to end its message. Do you have any idea how can I get
> around this problem. Any ideas and suggestions are more then welcomed.
>
> Thanks,
> Octav
>
> PS: My code is:
>
> import java.net.*;
> import java.io.*;
>
> public class Client1_0 {
>
> //Main method
> public static void main(String[] args) throws IOException
> {
> Socket NewSocket=null;
> PrintWriter out=null;
> BufferedInputStream in=null;
>
> //String HostName="cse-mfayad2.unl.edu";
> String HostName="cse.unl.edu";
> DataInputStream stdin= new DataInputStream(System.in);
>
> try
> {
> System.out.println("Starting to tests...");
> NewSocket=new Socket(HostName,21);
> out= new PrintWriter(NewSocket.getOutputStream(),true);
> in = new BufferedInputStream(NewSocket.getInputStream(), 1000);
> } catch (UnknownHostException e){
> System.err.println("Unknown host ("+HostName+")");
> System.exit(-1);
> } catch (IOException e) {
> System.err.println("Could not get IO access to "+HostName);
> System.exit(-1);
> };
> System.out.println("Connection to "+HostName+" established");
>
> byte i;
> String UI;
> int j;
> int size=0;
>
> while (size==0) size=in.available();
> for (j=0;j<size;j++) System.out.print((char)in.read());
>
> while (true)
> {
> UI=stdin.readLine();
> out.println(UI);
> try
> {
> in.wait();
> size=0;
> while (size==0) size=in.available();
> size=in.available();
> System.out.println("****"+size);
> for (j=0;j<size;j++) System.out.print((char)in.read());
> } catch (
> } catch (EOFException e) {
> System.err.println("OK");
> } catch (IOException e) {
> System.err.println("OK");
> };
> };
> };
> };
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail: webmaster@xml.apache.org
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org