[wxPython-users] Re: Having a single instance and forwarding document open requests

Doug Anderson doug at vitamindinc.com
Thu Sep 27 09:20:24 PDT 2007


Steve,

Thanks for your answers, but I don't think they are particularly  
useful in my case.

* Specifically, I am trying to support Windows, which doesn't have  
portmap on 111 (at least, not on my Windows box).  ...and yes, I know  
Windows is a pain in the butt sometimes, but I still need to support it.

* Yes, you can have multiple TCP connections through a single port  
number.  I have spent quite a bit of time with TCP/IP.  ...but I  
don't think you're understanding my usage model.  I'm writing a GUI  
app.  What does that mean?  Let's think through it on Windows (Mac  
and Unix have similar concepts, and yes I know that Unix came up with  
it first).  We'll choose port 12356, as an example.  If you log in  
with the user Steve and start up the app, it will now listen on port  
12356.  Now, I leave user Steve logged in and log in with user Doug.   
Now, the user Doug tries to start the GUI app.  If I don't choose a  
different port, Steve's program will get my TCP requests.

* Yes, my XMLRPC glance was very quick.  I will admit that.  If you  
think I should give it another glance (now that you understand my  
usage), I will.

* <Sigh> Sadly, ignorance is contagious.  I will admit that I have a  
pretty bad strain of it, but I am at least trying to get better.  ;)

-Doug

---

On Sep 27, 2007, at 11:02 AM, Steve Holden wrote:

> Doug Anderson wrote:
>> Thanks for all the quick responses.
>> I decided against TCP socket, mostly because:
>> - You've got to pick an arbitrary port and hardcode it.  If that  
>> port is taken, you are stuck with a really obscure failure case  
>> (not common, but I'm paranoid).
> Well, you could use the portmap service (port 111) if it's running.  
> That allows you to register a server at an arbitrary port number  
> and have clients find it by querying the portmapper. This is how  
> RPC-based services work.
>
>> - You can't support multi-user systems well (each user should have  
>> their own single instance), since their TCP sockets would collide.
> Incorrect. The server can have several connections active through a  
> single port number (how do you think Google and Amazon provide the  
> range of services they do)? The uniqueness requirement is on the tuple
>
>   (protocol, local port, local address, remote port, remote address)
>
> You should maybe take a look at the socket how-two.
>
>> I've never used XMLRCP, but my quick glance at it indicates that  
>> it suffers from similar problems (correct me if I'm wrong), since  
>> it runs on TCP.
> That was clearly a very quick glance indeed.
>> I've almost got a system working that uses files.  I have a  
>> listener thread watching a special directory for the appearance of  
>> files, which are used as a form of communication.  Not great, but  
>> it works even on windows (which doesn't seem to have mkfifo).  I  
>> figure out the listener thread with the SingleInstanceChecker (the  
>> warnings about stale lock files are a bit annoying, though I found  
>> a way around that with some google searching).
>> I guess my "kludgy" comment was more that with all of the advanced  
>> features of wxpython elsewhere, it surprised me that I had to jump  
>> through so many hoops and make so many design tradeoffs to solve  
>> what seemed like a relatively common problem.  ...but I know,  
>> programming is filled with such things.  ;)  WxPython at least  
>> makes it so I don't have to jump through as many hoops elsewhere  
>> in my code!
> Well, if you want to talk about "kludgey", your solution appears  
> kludgey in the extreme. Fortunately the reason for it is ignorance  
> of how TCP sockets actually work, and ignorance (which we all  
> suffer from) is curable.
>
> Perhaps you might take a look at
>
>   http://www.holdenweb.com/linuxworld/index.htm
>
> which has some basic TCP and UDP examples you can play with.
>
> regards
>  Steve
>
>> -Doug
>> ---
>> On Sep 26, 2007, at 10:23 PM, Dusty Phillips wrote:
>>> On 26/09/2007, Dusty Phillips <buchuki at gmail.com> wrote:
>>>>> For those unfamiliar, let me explain.  I want it so that if  
>>>>> someone
>>>>> double-clicks on one of my document files, it will either:
>>>>> - If no other copy of the app is running, it will start up the  
>>>>> application
>>>>> and open the document.
>>>>> - If another copy of the app is running, it will just tell that
>>>>> already-running copy to open the document.
>>>>>
>>>>> Another way to put it: I'd like to work like Visual Studio  
>>>>> works on Windows:
>>>>> opening a .c file from the file explorer doesn't open a  
>>>>> separate copy of
>>>>> visual studio.
>>>>
>>>> One interesting (aka: weird) way to do this is using tcp/ip,  
>>>> which is
>>>> supported on all modern systems.
>>>
>>>>> * My best idea so far is to use the wx.SingleInstanceChecker.   
>>>>> With it, I
>>>>> can prevent the second copy of the app from starting up, but I  
>>>>> can't
>>>>> communicate with it to tell it which documents to open.  I  
>>>>> could use an out
>>>>> of band communication method (TCP sockets, a file, ...), but  
>>>>> that seems very
>>>>> kludgy.
>>>
>>> Whoops, maybe I should have finished reading. ;-) I apologize. I
>>> personally disagree about TCP sockets being kludgy. They are fully
>>> supported, completely event driven, and don't take up a lot of
>>> overhead. Since you're connecting to localhost, you can probably get
>>> away with UDP sockets, with even less overhead; its unlikely packets
>>> would be dropped.
>>>
>>> Dusty
>>>
>>> -------------------------------------------------------------------- 
>>> -
>>> To unsubscribe, e-mail: wxPython-users- 
>>> unsubscribe at lists.wxwidgets.org
>>> For additional commands, e-mail: wxPython-users- 
>>> help at lists.wxwidgets.org
>>>
>
>
> -- 
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd           http://www.holdenweb.com
> Skype: holdenweb      http://del.icio.us/steve.holden
>
> Sorry, the dog ate my .sigline
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users- 
> help at lists.wxwidgets.org
>





More information about the wxpython-users mailing list