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 » Developing U++ » U++ Developers corner » U++ needs sockets examples and documentation
Re: U++ needs sockets examples and documentation [message #35018 is a reply to message #34810] Wed, 28 December 2011 17:09 Go to previous messageGo to previous message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
I know the socket API is simple, but what I really mean is how sockets are used with GUI apps.

For example: Do we need threads? How do make the sockets not block the GUI.
Lots of these questions could be answered with docs and examples (of sockets with GUI).

Also, I'd like to propose something to the U++ Dev Team, if it's not already been done.
In Tcl programming language I can use event-driven programming with sockets and it makes it really simple to not block the GUI and also handle multiple requests.
Here's a sample Tcl code that ilustrates that:

Server.tcl
# Read below to understand these 2 functions
proc readit {chan} {
    gets $chan data
    puts "We read $data from the socket."
}

proc writeit {chan} {
    # Now we can write something to the socket safely.
    puts $chan "Some data"
}

proc Serve {chan host port} {
   puts "IP $host connected through port $port on channel $chan."
   # Here is the interesting part. We set an event to the socket, and when it's readbale it'll execute the readit function and pass the channel as arg.
   fileevent $chan readable {readit $chan}
   fileevent $chan writable {writeit $chan}
}

# The line below creates a socket server and transfers control to the callback function
socket -server Serve 1234
# The line below waits in a infinite loop (only needed for console app)
vwait forever


Now this code could be used in a GUI app and it would not block the GUI through the use of events. It also handle multiples connects without the use of threads.
I don't know if U++ has anything like this, but it's a good feature to have.

[Updated on: Wed, 28 December 2011 17:11]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Web framework....
Next Topic: What are common software used in programing and used by software developers?
Goto Forum:
  


Current Time: Mon May 13 19:46:41 CEST 2024

Total time taken to generate the page: 0.02140 seconds