D
Darcy Ryan
Greetings,
I am having a problem trying to use the TcpClient and
NetworkStream classes to connect to a POP3 server. My
(simplified test) VB.NET code is as follows:
Dim tcpclient As New TcpClient
tcpclient.Connect("<server name>", 110)
Dim ns As NetworkStream = tcpclient.GetStream
Dim Rxbytes(tcpclient.ReceiveBufferSize) As Byte
ns.Read(Rxbytes, 0, CInt(tcpclient.ReceiveBufferSize))
Dim Txbytes As Byte() = Encoding.ASCII.GetBytes("USER
<name>\r\n")
ns.Write(Txbytes, 0, Txbytes.Length)
ns.Read(Rxbytes, 0, CInt(tcpclient.ReceiveBufferSize))
...
The code above will connect to the POP3 server and read
the "+OK ..." response for an active connection. The write
command executes ok, but the program hangs on the Read
command (as if the server has not recieved a valid USER
command). I have added a check for ns.DataAvailable prior
to the read, which returns no data available. I think that
I am missing something obvious in writing the USER command
(possibly with the CRLF).
I have verified my command strings by connecting to my
server using telnet, I have checked the samples on MSDN
and Google, and I am now into the 'banging head on
keyboard' stage.
Any advice?
Thanks,
Darcy
I am having a problem trying to use the TcpClient and
NetworkStream classes to connect to a POP3 server. My
(simplified test) VB.NET code is as follows:
Dim tcpclient As New TcpClient
tcpclient.Connect("<server name>", 110)
Dim ns As NetworkStream = tcpclient.GetStream
Dim Rxbytes(tcpclient.ReceiveBufferSize) As Byte
ns.Read(Rxbytes, 0, CInt(tcpclient.ReceiveBufferSize))
Dim Txbytes As Byte() = Encoding.ASCII.GetBytes("USER
<name>\r\n")
ns.Write(Txbytes, 0, Txbytes.Length)
ns.Read(Rxbytes, 0, CInt(tcpclient.ReceiveBufferSize))
...
The code above will connect to the POP3 server and read
the "+OK ..." response for an active connection. The write
command executes ok, but the program hangs on the Read
command (as if the server has not recieved a valid USER
command). I have added a check for ns.DataAvailable prior
to the read, which returns no data available. I think that
I am missing something obvious in writing the USER command
(possibly with the CRLF).
I have verified my command strings by connecting to my
server using telnet, I have checked the samples on MSDN
and Google, and I am now into the 'banging head on
keyboard' stage.
Any advice?
Thanks,
Darcy