T
Trecius
Hello, Newsgroupians:
I'm creating an application that will read emails from GMail, using the
System.Net.Sockets.TcpClient and POP protocol. However, I am having a
problem with my SslStream.
After I create the TcpClient, I create my SslStream...
stream = new System.Net.Security.SslStream(tcpclient.GetStream()...);
Now, unlike the MSDN documentation, I cannot read a <EOF>, for the POP
protocol doesn't have this, so I setup my read function as so...
byte[] buffer = new byte[2048];
int nBytesRead;
do
{
nBytesRead = stream.Read(buffer, 0, buffer.Length);
...
} while (nBytesRead != 0);
Let's pretend I authenticate, which sends a small message and the server
responds by sending "+OK Gpop ready for requests from 205.219.58.3
23903020fgae.0\r\n"
So, the first time I enter the do statement, it will read those bytes. As
nBytesRead does not equal 0, it will continue the loop. Well, now it tries
to read again, and it just hangs there until it times out.
Well, to alleviate the problem, I put a temporary break in the loop.
do
{
nBytesRead = stream.Read(buffer, 0, buffer.Length);
...
break;
} while (nBytesRead != 0);
Well, I can now read the response from GMail's pop server. This, again,
works for small messages. However, if the response from the server is
segmented, I receive only part of the message.
How can I ensure that I receive the entire message? I've tried setting the
stream's .ReadTimeout property and do a try-and-catch, but this method is
incorrect. Can anyone provide me direction into my predicament?
Thank you,
Trecius
I'm creating an application that will read emails from GMail, using the
System.Net.Sockets.TcpClient and POP protocol. However, I am having a
problem with my SslStream.
After I create the TcpClient, I create my SslStream...
stream = new System.Net.Security.SslStream(tcpclient.GetStream()...);
Now, unlike the MSDN documentation, I cannot read a <EOF>, for the POP
protocol doesn't have this, so I setup my read function as so...
byte[] buffer = new byte[2048];
int nBytesRead;
do
{
nBytesRead = stream.Read(buffer, 0, buffer.Length);
...
} while (nBytesRead != 0);
Let's pretend I authenticate, which sends a small message and the server
responds by sending "+OK Gpop ready for requests from 205.219.58.3
23903020fgae.0\r\n"
So, the first time I enter the do statement, it will read those bytes. As
nBytesRead does not equal 0, it will continue the loop. Well, now it tries
to read again, and it just hangs there until it times out.
Well, to alleviate the problem, I put a temporary break in the loop.
do
{
nBytesRead = stream.Read(buffer, 0, buffer.Length);
...
break;
} while (nBytesRead != 0);
Well, I can now read the response from GMail's pop server. This, again,
works for small messages. However, if the response from the server is
segmented, I receive only part of the message.
How can I ensure that I receive the entire message? I've tried setting the
stream's .ReadTimeout property and do a try-and-catch, but this method is
incorrect. Can anyone provide me direction into my predicament?
Thank you,
Trecius