Progress on preventing multiple instances of a program from running in windows

Alex Tweedly alex at tweedly.net
Fri Dec 3 12:14:58 EST 2004


At 09:34 03/12/2004 -0700, Dar Scott wrote:


>On Dec 3, 2004, at 8:57 AM, Frank D. Engel, Jr. wrote:
>
>>The operating system should prevent two different applications from
>>listening on the same port.  Rev shouldn't have to worry about that at
>>all.
>>
>>Rev has to go through the same APIs that C programs do (it is, after
>>all, written in C/C++, is it not?) so at some level or another, it will
>>be blocked from doing that, just as any other program would.
>>
>>OTOH, if Rev does not generate an error when this happens, it is indeed
>>a problem that Rev will need  to deal with.
>>
>>It *does* generate an error for me, though; check the value of "the
>>result" right after the "accept" command.  If the socket does not bind,
>>it will be nonempty.  At least, for me it is.
>
>I assume you mean "does bind".  What OS?

I think he did mean "does not bind".
If it does bind successfully, the result should empty (and the socket is 
now bound).
On the second try, it does NOT bind - so the result should be non-empty - 
probably some variant of "10048 Address in use".

>For me, on Mac OS 9.2 and on Windows XP I'm getting something fishy.
>
>It was some time ago on the Mac.  It might be that its listed twice but is 
>not really opened twice.
>
>On Windows XP, I'm getting no errors and netstat shows muliple listening 
>sockets on the same port.  I reported this as part of bug 828, the 
>original entry for the Mac problem.

>It might be that my system is messed up somehow.  Anybody else see this?

That's the same as I see on  Win2000.


>However, since I have seen this on the Mac...  Maybe not.  Maybe 
>Revolution is setting the bit to allow address-port pairs to be 
>re-used.  Maybe by accident or maybe for some purpose that I don't understand.

Cold be something like that - there's something very odd going on:

Start one server (in Rev Player) .... it reports no error, and gets any 
connections.

Start another server (in Rev IDE) .... reports no error, and connections 
continue to go to the Player version.

Stop (i.e. resetAll) in the Player server - and connections now go to the 
Rev IDE instance.

Restart the Player instance - connections continue to go to the IDE instance.

Stop (resetAll) the IDE version  - Player version now gets any connections.


BUT .....

close all servers, verify that connections are "refused" - i.e. no server 
listening on the port.

Start up the Rev IDE server ... it gets connections
Start up my Python-based server ... it gives error "Address already in use"
Stop Rev Server
Start Python server - no error, it gets connections
Start Rev server - no error AND IT GETS ANY NEW CONNECTIONS.

The rev server has pre-empted an existing, listening server.   Very odd.


>I don't have a problem on OS X.  There I get an error message in the 
>result if the port is in use for accept.

Maybe I'll just give up this Windows nonsense and switch to Mac :-)

-- Alex.


More information about the use-livecode mailing list