473,382 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Socket communication to POP3 problem

Hi,
I developed an application to read email from POP3 server. Some of the
codes are below:
-------------------------------------------------------------------------------
Server = new TcpClient(_MailServer, 110);
......
private string sendCommand(string command) {
byte[] szData;

NetStrm = Server.GetStream();
RdStrm = new StreamReader(Server.GetStream());
RdStrm.DiscardBufferedData();

// add CRLF to the command
command += "\r\n";

szData = System.Text.Encoding.ASCII.GetBytes(command.ToChar Array());
NetStrm.Write(szData, 0, szData.Length);
//NetStrm.Flush();

string s = "";

while(RdStrm.Peek() > -1) {
s += RdStrm.ReadLine() + "\r\n";
}
return s;
}
-------------------------------------------------------------------------------
This is the core function to read data from socket.

In POP3 command there is one "RETR 1" to read all content of email. It
should return something like:
-------------------------------------------------------------------------------
+OK 2134 octets
Date: Mon, 24 Jan 2005 11:38:19 -0500
Message-Id: <20***********************@company.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
From: "Hardy Wang" <ha********@company.com>
Reply-To: <ha********@company.com>
To: <te**@company.com>
X-Mailer: <IMail v8.15>
X-RCPT-TO: <te**@company.com>
Status: U
X-UIDL: 406403936

Body of email....
-------------------------------------------------------------------------------
It works fine on my local machine (machine1), on one of the server
(server1), I can get all the content properly. But after I moved program to
another server (server2), RdStrm.Peak() will return -1 after retrieving
first line of content, which is "+OK 2134 octets" (drive me mad!). My next
POP3 command is "DELE 1" to remove this mail, at this step socket stream
returned the remaining part of mail content! So it looks there is a delay.
On my local machine (against same POP server as server2), RdStrm.Peak()
won't return -1 until I have all content in stream returned (good).
machine1 <--> POP3
server2 <--> POP3

My question is in which situation, socket will return stream differently
against same target? Both machines have .Net 1.1 and service pack 1
installed.

Thanks for any suggestion!
--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 16 '05 #1
0 1278

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lindstrom Greg - glinds | last post by:
Hello- I have a python routine (Python 2.2.3 on Windows 2000 "Professional") using a socket connection. Problem is, the backend service I'm connecting to will hang every so often and the socket...
4
by: faktujaa | last post by:
Hi, I am having some problem with callback used in socket implementation. private static void Connect(string strPrtrIPAddr, int intPrtrPort, ref Socket rsocClient) { try { // Create remote end...
2
by: tantiboh | last post by:
I'm not a new programmer, but this one's got me stymied; hopefully it's a fairly trivial problem. I'm using a socket connection to receive communication from a server. Normally, the entire message...
3
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work...
4
by: Sačo Zagoranski | last post by:
Hi! I'm writing a simple 3D First person shooter game. It is a multiplayer game, where all the players connect to one server.
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
1
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to...
0
by: =?Utf-8?B?QWxwZXIgQUtDQVlPWg==?= | last post by:
Hello, First of all I wish you a good day. My help request is about .NET asynchrounus socket communication. I have developed Server-Client Windows Forms .NET applications in VC++ .NET v2003. I...
0
by: Mangabasi | last post by:
Howdy, I would like to use the Synthesis Toolkit for a demo. I downloaded the STK from http://ccrma.stanford.edu/software/stk/index.html. It seems very powerful and user friendly. There are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.