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
Camon Zixahourz
NA
5
0
Problems With Exceptions and Sockets
May 22 2005 1:58 PM
I want to implement a TCP Listener wich Listens for 1 min if there is no connection pending i want to restart the whole process of creating the listener, this is because i'm implementing a state machine. try { do { retry = false; char[] mensaje = SMS.BuildMessageforRemota(name,destnum, port); //SMS.SendMessage(mensaje); //Making the TCPListener to Listen MyListener.Start(); myTimer.Change(0, 60000); Server(MyListener.AcceptSocket()); //if this is succesfully a blocking call then program flow //will be hold here until i have someone that has connected //or the Timer Stops the Listener } while (retry && attempts < 3); the routine wich is called by my timer: public void ResetConnectionAttemp(Object State) { attempts++; //increase the amount of attempts retry = true; if (MyListener != null) { MyListener.Stop(); } } now, when i call MyListener.Stop(), i get a SocketException because i make an unblocking call to the BlockingCall made by MyListener.AcceptSocket(), is there a way to avoid this exception, because this is exactly what i want to make, hold the program execution for 1 min, then stop it, and resend the SMS to wakeup whoever is going to connect with me,(if it doesn't works the first time, is because the message didn't arrive, that's why i need to resend it), another option is, is there a possibility to make a timeout for the listener, wich will close the connection by itself without throwing the exception without the Timer class?? thanks!!!
Reply
Answers (
4
)
Checking for variable existance in C# as cfparam in CFM
How to get user data from Active Directory