Results 1 to 2 of 2
Thread: POP3 Client Socket Problem
- 02-15-2012, 02:49 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 16
- Rep Power
- 0
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
POP (where the problem lies)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); } } }
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) { } } }
- 02-15-2012, 03:09 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Java Socket server with C client problem
By rnvrnv in forum NetworkingReplies: 6Last Post: 11-09-2010, 12:47 AM -
Client Server socket problem - help needed
By kellaw in forum Threads and SynchronizationReplies: 6Last Post: 10-03-2008, 06:49 PM -
Problem with Socket Client - Intermittent Truncated Response in AIX
By cheongww in forum NetworkingReplies: 4Last Post: 10-02-2008, 06:32 PM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks