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
U++ needs sockets examples and documentation [message #34810] Tue, 13 December 2011 16:19 Go to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
In my opinion the GUI examples provided with U++ are enough, but it really lacks examples for sockets and web packages.

Yeah, there are a few simple examples using Http. But there's no big example, for example a GUI chat program.
So, it doesn't show how the Web packages work when using the GUI framework.
Re: U++ needs sockets examples and documentation [message #34849 is a reply to message #34810] Wed, 14 December 2011 17:35 Go to previous messageGo to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
yes, i think you're right!
some examples how to use the web package and what is possible with it would be great

and maybe it isn't a bad idea to have a look at the examples / reference already avaiable if they are still correct?!

( http://www.ultimatepp.org/forum/index.php?t=msg&goto=347 65&S=c7bff5e21e848aa8f653eab654b5f371#msg_34765 )
Re: U++ needs sockets examples and documentation [message #34853 is a reply to message #34849] Thu, 15 December 2011 08:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
The thing here is that we are now developing "web framework", which will probably result in major overhaul. I guess it makes more sense to enhance docs after this is finished...
Re: U++ needs sockets examples and documentation [message #34985 is a reply to message #34853] Sat, 24 December 2011 02:31 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
mirek wrote on Wed, 14 December 2011 23:22

I guess it makes more sense to enhance docs ...


Good idea, the docs are much better now than a year or so ago.

lectus: The concept of sockets are simple and straight forward (perhaps if you have used simple examples).
server/client: client contacts server then server can respond.

I have not gotten into the web stuff much but an IP along with a port # should do it.

Do a google search for "socket chat python".
Python usually has very simple examples with good explanations.
Once you understand the concepts and the basics you can port that to U++.

Try also changing your search to the Java language.
If you can find something to fit your needs in C++ then it should work in U++.

If not just post the code you are having a problem with (ie: put a bit of effort into it first, you will learn more, understand the concepts better and may/should be able to get something working).

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 next 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

Re: U++ needs sockets examples and documentation [message #35022 is a reply to message #35018] Thu, 29 December 2011 15:47 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

A good solution (tested on nodejs) can be libuv library. Exists other events library like zeromq but those does not have native cross compilation.
Previous Topic: Web framework....
Next Topic: What are common software used in programing and used by software developers?
Goto Forum:
  


Current Time: Fri Mar 29 14:23:52 CET 2024

Total time taken to generate the page: 0.02168 seconds