• Lucid Dreaming - Dream Views




    Results 1 to 1 of 1
    1. #1
      Member Achievements:
      Created Dream Journal Referrer Bronze 5000 Hall Points Tagger First Class Populated Wall Veteran First Class
      Arra's Avatar
      Join Date
      Jan 2011
      Posts
      3,838
      Likes
      3887
      DJ Entries
      50

      Java Server-Client Difficulty

      (I'm drinking, so excuse any poor grammar/spelling/bad explanations).

      I have an assignment due 2 hours ago, but I can get it done 24 hours past the due date with -20%. I've never done client-server applications before. If it seems like I've given rediculously little information, don't yell at me, just leave, I'm sorry. I'll probably get no answers.

      I don't want to post a lot of code, I just want input from anyone who's very familiar with client-server Java programs. I'm not going to explain this very well at all, and it will probably only be understandable to someone who knows about the subject very well. I only have one basic question, near the end, the bolded text. The rest is just background information.

      in = new Scanner(socket.getInputStream());
      out = new PrintWriter(socket.getOutputStream());

      That is in the Server's Service, and there are similar variables in the client for getting input and output from the server.

      It seems that sometimes, when I go out.println("some message") in the server which should be sent to the in.nextLine() in the client, it will return an empty string. I have a loop which prints a few messages. But I've traced the program several times, printing out each message before it's sent, and there is no reason at all the server should be printing out an empty string, ever. But it does. So I must not be understanding something.

      So I'm wondering, does in.nextLine() wait for some String from the server before returning the message, or does it just return an empty string if there is no message right away? Do I have to write a while(!in.hasNext()); before every in.nextLine(), or something similar?

      This is the only thing I can see might possibly be happening. If it isn't this, I might just have to give up on this assignment, becuase I don't know what else to try. I've tried everything I can think of.
      Last edited by Dianeva; 04-09-2011 at 09:57 AM.

    Similar Threads

    1. Substitute for SmartFTP Client?
      By Adam in forum Tech Talk
      Replies: 5
      Last Post: 09-14-2008, 05:59 AM
    2. Need an FTP Client
      By Adam in forum Tech Talk
      Replies: 7
      Last Post: 11-05-2007, 01:22 AM

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •