Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Socket in a sock
Re: Socket in a sock [message #17541 is a reply to message #17539] Tue, 19 August 2008 22:13 Go to previous message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Quote:

All this work has to be made without interrupting the other application works, like logging contacts to a database, moving a rotor antenna via com port, etc. not a continuous work, maybe a TimerCallback is the better option to read the buffer socket every 500 milliseconds

You will need to thread the outgoing connection. What I would do is create a class that would handle outgoing connections (make the connection and read from the buffer) and use the U++ Thread to run a class method. Have that thread run a loop checking for new information on the socket. When it receives information, it could update the Gui. Meanwhile, it would not block the program from doing other things, and the thread would terminate after the function exits (on socket close). You have to be careful with the architecture in this scenario with threading and race conditions though. For example, what if you want to close the program while it is listening for connections (thread running)? How do you end the thread and close the socket? You probably will need to use shared resources and locking in this situation, In this case I would look into making a thread-safe class method that would close the socket and have the function that is running in the thread finish/exit if the socket is closed.

Also, remember that BSD socket connections close when both sides close the socket. The close message that is sent is acknowledged by the other side to officially close the connection.

Sorry I cannot check out the telnet site right now, but I might be able to get to it in a bit.

[Updated on: Tue, 19 August 2008 22:14]

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message icon3.gif
Read Message
Previous Topic: sending post message
Next Topic: Socket documentation
Goto Forum:
  


Current Time: Sun Apr 28 10:57:29 CEST 2024

Total time taken to generate the page: 0.02452 seconds