Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default POP3 Client Socket Problem

    Hi everyone, so I'm making a very simple application to send and receive mail through the Mercury server using sockets, it's part of a tutorial for a client-server programming module I'm doing. The problem lies in the "pop" class.

    I created a "smpt" class to send a very simple message, I've set up some local users through Mercury (I'm sure your aware real addresses can't be used for obvious reasons). It sends the message fine, I've tested it through telnet. I've set up a "pop" class to receive the message but this is where the problem lies, I've set it up as best I can but Netbeans is giving me an error on line 24 and 31 (the While statements) it says: "cannot find symbol, symbol: method readLine(), location: variable is of type java.lang.Object.

    Any help much appreciated, I'm sure it's something ridiculously simple but I'm a bit of a newbie.

    My classes are as follows:

    SMPT

    Java Code:
    package email;
    
    
    import java.io.DataOutputStream;
    import java.io.IOException;
    import java.net.Socket;
    import java.util.Scanner;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    public class smtp {
    
        public static void main(String[] args) {
            String responseLine;
            try {
              Socket  s = new Socket("localhost", 25);
    
                DataOutputStream os =
                        new DataOutputStream(s.getOutputStream());
    
                Scanner ss = new Scanner(s.getInputStream());
    
                os.writeBytes("HELO\n");
                os.writeBytes("MAIL From: <freddie@localhost>\n");
                os.writeBytes("RCPT To: <david@localhost>\n");
                os.writeBytes("DATA\n");
                os.writeBytes("From: test1@localhost\n");
                os.writeBytes("To: Daniel2.Aspey-Smith@live.uwe.ac.uk\n");
                os.writeBytes("Subject: Testing\n\n");
                os.writeBytes("Hi there the time is 12:10\n");
                os.writeBytes("\n.\n");
                os.writeBytes("QUIT\n");
    
                while (ss.hasNextLine()) {
                    responseLine = ss.nextLine();
                    System.out.println("Server: "+responseLine);
                }
            } catch (IOException ex) {
                Logger.getLogger(smtp.class.getName()).log(Level.SEVERE, null, ex);
            }
    
    
    
        }
    }
    POP (where the problem lies)

    Java Code:
    package email;
    
    import java.io.DataOutputStream;
    import java.io.IOException;
    import java.net.Socket;
    
    public class pop {
    
        private static Object is;
    
        public static void main(String[] args) {
    
            try {
    
                Socket s = new Socket("localhost", 110);
    
                DataOutputStream os =
                        new DataOutputStream(s.getOutputStream());
    
                os.writeBytes("user david\n");
                os.writeBytes("pass tellno1\n");
                os.writeBytes("list\n");
                String responseLine;
                while ((responseLine = is.readLine()) != null)    {
                    System.out.println("Server: " + responseLine);
                    if (responseLine.equals(".")) {
                        break;
                    }
                }
                os.writeBytes("retr 1\n");
                while ((responseLine = is.readLine()) != null)    {
                    System.out.println("Server: " + responseLine);
                    if (responseLine.equals(".")) {
                        break;
    
                    }
    
                }
    
            } catch (IOException e) {
            }
    
        }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,001
    Rep Power
    20

    Default Re: POP3 Client Socket Problem

    'is' is a reference to an Object.
    Object does not have a readLine() method.

    EVen if you did manage to get this to compile you would then get a NullPointerException as I don't see you initialising 'is' anywhere in that main() method.

Similar Threads

  1. Java Socket server with C client problem
    By rnvrnv in forum Networking
    Replies: 6
    Last Post: 11-09-2010, 12:47 AM
  2. Client Server socket problem - help needed
    By kellaw in forum Threads and Synchronization
    Replies: 6
    Last Post: 10-03-2008, 06:49 PM
  3. Replies: 4
    Last Post: 10-02-2008, 06:32 PM
  4. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 09:18 AM

Posting Permissions

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