Re: [Ntw-devel] NTW mod for setting port value using -p
Status: Beta
Brought to you by:
drblast
|
From: Yua C. <ca...@gz...> - 2006-06-23 18:13:13
|
My main problem is trying to fit this into the current framework ( less work overall, but more thinking. :)) ) Right now, it's easy enough to create a timer id using g_timeout_add(interval, callback fn, data) where: 1. interval is set by the user 2. callback fn could be the sync/async _event_handler 3. data is NULL ( since it's just a timer ) If we were to use sync/async _event_handler, we would need to make the widget a "real" widget somehow with real events and such. ie, event_send(wt->address, TRUE/FALSE, eventid, NULL, 0); where wt ( the Widget Table ) address points to a "real" widget somewhere and eventid is some int32. Any clues? Yua Ca Van ----- Original Message ----- From: "Ian Larsen" <dr...@gm...> To: "Yua CaVan" <ca...@gz...> Cc: <ntw...@li...> Sent: Thursday, June 22, 2006 7:24 PM Subject: Re: NTW mod for setting port value using -p > Sorry, wrong link. > > Take a look at g_timeout_add. That's the new way to add a timed event > to the main event loop, and has a callback. > > -Ian > > > On 6/22/06, Yua CaVan <ca...@gz...> wrote: >> I don't know if I'm a fan of the g_timer_* stuff. There aren't any >> callbacks and we have to explicitly check each timer value. >> >> Yua Ca Van >> ----- Original Message ----- >> From: "Ian Larsen" <dr...@gm...> >> To: "Yua CaVan" <ca...@gz...> >> Cc: <ntw...@li...> >> Sent: Thursday, June 22, 2006 4:59 PM >> Subject: Re: NTW mod for setting port value using -p >> >> >> > That looks about right, >> > >> > It's really not any different than many of the widgets that have >> > "default" events associated with them, like the text entry widget. >> > Everytime the text of an entry widget changes, an event is fired and >> > the new text is sent to the server. >> > >> > So the timer wouldn't require any special handling. The glib timer >> > functions make it all pretty simple. (These have been moved from GTK >> > to GLib) >> > >> > http://www.gtk.org/api/2.6/glib/glib-Timers.html >> > >> > -Ian >> > >> > >> > >> > >> > >> > >> > On 6/22/06, Yua CaVan <ca...@gz...> wrote: >> >> I've thought about this some... if we were to do the timer >> >> client-side, >> >> we >> >> would need to write up a special timer function to send a request to >> >> the >> >> server to run the callback function, am I right? >> >> >> >> ie... >> >> [ client side timer widget ] >> >> struct __timerData { >> >> GtkFunction * cbFn; >> >> gpointer * cbData; >> >> } timerData; >> >> >> >> timerData td; >> >> >> >> function run_timer_callback(gpointer * data) { >> >> /* >> >> * Send request back to server to run the callback function >> >> */ >> >> } >> >> >> >> function make_timer_widget(ntwWidget* widget, gint timeout, >> >> GtkFunction * >> >> callback, gpointer * data) { >> >> td.cbFn = callback; >> >> td.cbData = data; >> >> >> >> widget = gtk_timeout_add(timeout, (GtkFunction*)run_timer_callback, >> >> (gpointer*)&td); >> >> // add this widget to the widget table >> >> } >> >> ----- Original Message ----- >> >> From: "Ian Larsen" <dr...@gm...> >> >> To: "Yua CaVan" <ca...@gz...> >> >> Sent: Monday, June 19, 2006 5:00 PM >> >> Subject: Re: NTW mod for setting port value using -p >> >> >> >> >> >> > I'll keep that in mind. What do you think of having the timer stop >> >> > automatically, and only start again when the server issues a >> >> > "restart" >> >> > message? That way a server wouldn't get bogged down with unhandled >> >> > timer messages. >> >> > >> >> > -Ian >> >> > >> >> > On 6/19/06, Yua CaVan <ca...@gz...> wrote: >> >> >> sounds like a plan. :) I haven't used timers under GTK or QT, but >> >> >> if >> >> >> there's already an implementation, then it's silly not to use it. >> >> >> :) >> >> >> >> >> >> I still think that it'd be a good idea to supply the "stop timer" >> >> >> and >> >> >> "change timeout" messages so the client can stop and/or change >> >> >> timeout >> >> >> values. ie, very time intensive code would require a "stop timer" >> >> >> to >> >> >> be >> >> >> issued until completion of the task. That's my normal >> >> >> modus-operendus >> >> >> when >> >> >> doing async timeouts. After the task is completed, I restart the >> >> >> timer. >> >> >> >> >> >> Sometimes, you may want to change the timeouts... ie, if this is an >> >> >> email >> >> >> application, the user may want the option to change the frequency >> >> >> in >> >> >> which >> >> >> s/he grabs email from the mail server. >> >> >> >> >> >> Yua Ca Van >> >> >> ----- Original Message ----- >> >> >> From: "Ian Larsen" <dr...@gm...> >> >> >> To: "Yua CaVan" <ca...@gz...> >> >> >> Sent: Monday, June 19, 2006 4:45 PM >> >> >> Subject: Re: NTW mod for setting port value using -p >> >> >> >> >> >> >> >> >> > Originally, my thought was to do the timer as a server side >> >> >> > widget >> >> >> > like that, but I thought it might be better to have a client side >> >> >> > timer, that sends an event to the server. >> >> >> > >> >> >> > The reasons are that properly handling multiple timers on a >> >> >> > multithreaded server serving many clients is hard. Also, with >> >> >> > the >> >> >> > network latency being a factor, I don't think the millisecond >> >> >> > latency >> >> >> > would ever be necessary. Finally, I'm sure there are some >> >> >> > programming >> >> >> > languages where supporting timer interrupts would be non-trivial >> >> >> > or >> >> >> > impossible. (The Common Lisp server uses a select-based event >> >> >> > loop >> >> >> > to >> >> >> > distribute processing among clients, a timer would be very >> >> >> > difficult >> >> >> > to do there.) >> >> >> > >> >> >> > Since GTK and QT both have timers already, I thought that a >> >> >> > client-side timer widget would be extremely easy to implement, >> >> >> > wouldn't complicate the server at all, and would be usable by any >> >> >> > programming language. It would simply send a "NTW_TIMEOUT" event >> >> >> > at >> >> >> > a >> >> >> > specified interval. That way, all servers could handle that >> >> >> > event >> >> >> > with a callback as with any other event. >> >> >> > >> >> >> > Let me know if I'm missing something. >> >> >> > >> >> >> > -Ian >> >> >> > On 6/19/06, Yua CaVan <ca...@gz...> wrote: >> >> >> >> lol. I was just thinking about that as well. :) >> >> >> >> >> >> >> >> The primary concern for a Timer widget is threading. PThreads >> >> >> >> should >> >> >> >> work >> >> >> >> under all OSes. >> >> >> >> The Timer Widget could be created with the timeout in >> >> >> >> milliseconds >> >> >> >> and >> >> >> >> you >> >> >> >> can add a callback via ntw_add_callback(), ie: >> >> >> >> >> >> >> >> ntwWidget * timer1; >> >> >> >> ntwWidget * timer1Timeout; >> >> >> >> >> >> >> >> timer1 = ntw_timer_new(1000); >> >> >> >> ntw_add_callback(timer1, TIMER_EVENT, (func_ptr)&timer_ping, >> >> >> >> timer, >> >> >> >> ASYNC); >> >> >> >> >> >> >> >> the Timer widget could have pause() and set() functions to stop >> >> >> >> the >> >> >> >> timer >> >> >> >> and to change the timeout. >> >> >> >> >> >> >> >> What do you think? >> >> >> >> ----- Original Message ----- >> >> >> >> From: "Ian Larsen" <dr...@gm...> >> >> >> >> To: "Yua CaVan" <ca...@gz...> >> >> >> >> Sent: Monday, June 19, 2006 4:03 PM >> >> >> >> Subject: Re: NTW mod for setting port value using -p >> >> >> >> >> >> >> >> >> >> >> >> > Yua, >> >> >> >> > >> >> >> >> > Thanks for the kind words. The file upload and download would >> >> >> >> > be >> >> >> >> > a >> >> >> >> > great addition. The reason it's not in there already is >> >> >> >> > because >> >> >> >> > I >> >> >> >> > figured it would be a security issue and didn't want to deal >> >> >> >> > with >> >> >> >> > that >> >> >> >> > until I had plenty of time. But it wouldn't be hard to do at >> >> >> >> > all -- >> >> >> >> > the buffered images would be a good starting point, as they >> >> >> >> > save >> >> >> >> > to >> >> >> >> > disk on the client side already. >> >> >> >> > >> >> >> >> > But as for going beta, the only other thing I'd really like to >> >> >> >> > add >> >> >> >> > is >> >> >> >> > a timer widget that would cause an event every N seconds. >> >> >> >> > >> >> >> >> > -Ian >> >> >> >> > >> >> >> >> > >> >> >> >> > On 6/19/06, Yua CaVan <ca...@gz...> wrote: >> >> >> >> >> No problem, Ian. Just happened to notice that a network >> >> >> >> >> framework >> >> >> >> >> is >> >> >> >> >> kinda >> >> >> >> >> useless if people aren't able to specify which port they can >> >> >> >> >> run >> >> >> >> >> their >> >> >> >> >> servers on. ;) >> >> >> >> >> >> >> >> >> >> btw, I totally LOVE this framework. :) >> >> >> >> >> >> >> >> >> >> I would like to see how we could implement file upload ( >> >> >> >> >> loading >> >> >> >> >> files >> >> >> >> >> to >> >> >> >> >> work on, if someone were to write a word processor ) and file >> >> >> >> >> download >> >> >> >> >> ( >> >> >> >> >> saving files as in the afforementioned word processor ). At >> >> >> >> >> that >> >> >> >> >> point, >> >> >> >> >> the >> >> >> >> >> framework could very easily go Beta and you could have MS >> >> >> >> >> buying >> >> >> >> >> this >> >> >> >> >> widget >> >> >> >> >> system from you. lol. J/K! :D >> >> >> >> >> >> >> >> >> >> Yua Ca Van >> >> >> >> >> ----- Original Message ----- >> >> >> >> >> From: "Ian Larsen" <dr...@gm...> >> >> >> >> >> To: "Yua CaVan" <ca...@gz...> >> >> >> >> >> Sent: Monday, June 19, 2006 2:59 PM >> >> >> >> >> Subject: Re: NTW mod for setting port value using -p >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > Yua, >> >> >> >> >> > >> >> >> >> >> > Thank you very much for the patch. I'll put it in and >> >> >> >> >> > alter >> >> >> >> >> > the >> >> >> >> >> > documentation as you recomended. >> >> >> >> >> > >> >> >> >> >> > Thanks again, >> >> >> >> >> > Ian Larsen >> >> >> >> >> > >> >> >> >> >> > On 6/19/06, Yua CaVan <ca...@gz...> wrote: >> >> >> >> >> >> Please find attached: >> >> >> >> >> >> 1. ntw_port_mod.tgz >> >> >> >> >> >> >> >> >> >> >> >> This tar-gzipped file contains 4 files: >> >> >> >> >> >> 1. network.h >> >> >> >> >> >> 2. network.c >> >> >> >> >> >> 3. ntw.c >> >> >> >> >> >> 4. PORTMOD >> >> >> >> >> >> >> >> >> >> >> >> This mod allows a person to set the port to run the server >> >> >> >> >> >> on >> >> >> >> >> >> by >> >> >> >> >> >> using >> >> >> >> >> >> the >> >> >> >> >> >> following syntax: >> >> >> >> >> >> serverprogram -p port >> >> >> >> >> >> >> >> >> >> >> >> ie, ntwserver -p 1024 >> >> >> >> >> >> >> >> >> >> >> >> I would also put in the documentation to remove -DDEBUG >> >> >> >> >> >> from >> >> >> >> >> >> the >> >> >> >> >> >> Makefile >> >> >> >> >> >> if >> >> >> >> >> >> the person running ntw wishes to run the server as a >> >> >> >> >> >> forking >> >> >> >> >> >> server. >> >> >> >> >> >> :) >> >> >> >> >> >> >> >> >> >> >> >> These files were modded from the ntw-0.3 release. >> >> >> >> >> >> >> >> >> >> >> >> Yua Ca Van >> >> >> >> >> >> >> >> >> >> >> >> This transmission many contain information that is >> >> >> >> >> >> privileged, >> >> >> >> >> >> confidential >> >> >> >> >> >> and exempt from disclosure under applicable law. If you >> >> >> >> >> >> are >> >> >> >> >> >> not >> >> >> >> >> >> the >> >> >> >> >> >> intended >> >> >> >> >> >> recipient, you are hereby notified that any disclosure, >> >> >> >> >> >> copying, >> >> >> >> >> >> distribution or use of the information contained herein >> >> >> >> >> >> (including >> >> >> >> >> >> any >> >> >> >> >> >> reliance thereon) is STRICTLY PROHIBITED. If you received >> >> >> >> >> >> this >> >> >> >> >> >> transmission >> >> >> >> >> >> in error, please immediately contact the sender and >> >> >> >> >> >> destroy >> >> >> >> >> >> the >> >> >> >> >> >> material >> >> >> >> >> >> in >> >> >> >> >> >> its entirety, whether in electronic or hard copy format. >> >> >> >> >> >> <----- GZ Link, Inc. (c) 2006 All Rights Reserved ------> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> >> >> >> > >> > >> >> >> > > |