TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ryan taylor
NA
1
0
BindIPEndPoint Delegate with SmtpClient causes endless loop
Nov 12 2010 6:04 AM
So I'm trying to use the BindIPEndPoint when sending an email but its causing an endless loop of calling BindIPEndPointCallback. It's driving me nuts and I cant figured out the cause.
I created a new test project and used the same methods and tried doing a HttpWebRequest with BindIPEndPointCallBack and it worked properly... is the System.Net.Mail.ServicePoint.BindIPEndPointDelegate broken?!
private
string
servicePointIP;
public
string
ServicePointIP
{
get
{
return
servicePointIP; }
set
{ servicePointIP = value; }
}
public
delegate
IPEndPoint BindIPEndPoint(ServicePoint servicePoint, IPEndPoint remoteEndPoint,
int
retryCount);
private
IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint,
int
retryCount)
{
Console.WriteLine(
"BindIPEndPoint Called"
);
if
(retryCount < 3 && servicePointIP !=
null
)
return
new
IPEndPoint(IPAddress.Parse(servicePointIP), 0);
else
return
new
IPEndPoint(IPAddress.Any, 0);
}
private
string
SendMail(MailMessage msg, IPAddress ip)
{
servicePointIP =
"192.168.1.9"
;
SmtpClient smtp =
new
SmtpClient();
smtp.Host =
"localhost"
;
smtp.Port = 25;
smtp.ServicePoint.BindIPEndPointDelegate =
new
System.Net.BindIPEndPoint(BindIPEndPointCallback);
smtp.Send(msg);
}
Reply
Answers (
0
)
System.Threading.Tasks - Limit the number of concurrent Tasks
Why form does not die evn object has been destroyed