I am attempting to loop through emails from a POP3 server and retrieve their attachments. Unfortunately, when I attempt to list an email that does not exist, my application hangs.
It appears to be hanging on the receive of the data. I attempted to have it return an error when the socket.Availabe was 0, but then it always returned an error.
Does anyone know what is going on? Why is my app hanging? If the server is returning nothing, do you know why? What does it all mean?
Below is a screen dump of a telnet session that I used to test that it was possible.
[tt]
list
+OK 2 3842
1 1572
2 2270
.
list 1
+OK 1 1572
list 2
+OK 2 2270
list 3
-ERR The specified message is out of range.
[/tt]
This is the log from the session for my application.
[tt]
list
+OK 2 3842
1 1572
2 2270
.
list 1
+OK 1 1572
list 2
+OK 2 2270
list 3
[/tt]
The code hangs at this point (I assume because there is no response). Infact, I checked and the app is hanging on the socket.receive().
It appears to be hanging on the receive of the data. I attempted to have it return an error when the socket.Availabe was 0, but then it always returned an error.
Does anyone know what is going on? Why is my app hanging? If the server is returning nothing, do you know why? What does it all mean?
Below is a screen dump of a telnet session that I used to test that it was possible.
[tt]
list
+OK 2 3842
1 1572
2 2270
.
list 1
+OK 1 1572
list 2
+OK 2 2270
list 3
-ERR The specified message is out of range.
[/tt]
This is the log from the session for my application.
[tt]
list
+OK 2 3842
1 1572
2 2270
.
list 1
+OK 1 1572
list 2
+OK 2 2270
list 3
[/tt]
The code hangs at this point (I assume because there is no response). Infact, I checked and the app is hanging on the socket.receive().
Code:
byte[] buffer = new byte[MAX_BUFFER_READ_SIZE];
string line = null;
int byteCount;
try{
byteCount = sock.Receive(buffer,buffer.Length,0);
line = Encoding.ASCII.GetString(buffer, 0, byteCount);
}
return(line);