Top.Mail.Ru
January 22nd, 2005 - Java developers — LiveJournal
? ?

Java developers

January 22nd, 2005
Image

02:10 pm - Imageska_o

Did anyone here ever use Standard Widget Toolkit for GUI development? Comments?
Image

06:17 pm - Imagemharmless - Reading Lines from Socket...

What seems like a basic socket connection question:

The program first initiates the Socket Connection, to which the server should reply:



"$lock [some random String]
$servername [name of the server]"

To which I have to reply:
"$key [some String found by $lock]
$username [client username]"

Now when I execute this program, I only receive the $lock and not the $servername.

Now the problem might be that i use...
String inLine = input.readLine();


Does the readLine() only read one line?
It seems as if the program is attempting to get more info from the server because it hangs until the server drops the connection.

How do I read everything that the server is trying to send to me?

Source:
    public static void EstablishConnection (String[] args) {

        System.out.println("-- Program Started!");

        Socket server = null;
        BufferedReader input = null;
        PrintWriter output = null;

        String serverIP = "192.168.1.104";
        String key = null;
        int portNum = 1090;

        try {
            server = new Socket(serverIP, portNum);
            output = new PrintWriter(server.getOutputStream(), true);
            input = new BufferedReader(new InputStreamReader(server.getInputStream()));
        } catch (UnknownHostException e) {
            e.printStackTrace();
            System.exit(100);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(101);
        }

        try {
            String inLine = input.readLine();
            key = breakLock(inLine.substring(inLine.indexOf(' ') + 1, inLine.length()));

            System.out.println("<< " + inLine);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(101);
        }

        String outLine = ("$key " + key + "\n$nick connectTo");
        output.print(outLine);
        System.out.println(">> " + outLine);

    }


By the way, what's the syntax for the ljcut?
Image

08:57 pm - Imagethecuddlebug

alright...

I am desperate for help with my java final.

anyone interested?

I offer my lifelong friendship in return :)

Or you know... money, whatever ya want.
Powered by LiveJournal.com
Image