I am fairly new to python and seem to have gotten ahead of myself. I
am trying to write a Windows service that will return the current
number of Citrix sessions to a client. This service will run on my
Citrix servers for usage tracking purposes.
The service itself seems to function properly, it starts, stops, logs
to the event viewer, etc. The problem seems to be with the portion
where it either waits to be stopped or waits for remote connection - it
does not get to the 'wait for remote connection' part.
If I remove the 'wait for stop request' portion the service will return
the session count but of course I can't stop the service nicely.
Does anyone have some example code I could take a look at or some
advice to get me back on track?
thanks in advance,
John
s = socket.socket()
hostIP = socket.gethostb yaddr(socket.ge thostname())[2][0]
if debug == 'true': servicemanager. LogInfoMsg('Hos t IP: ' +
str(hostIP))
s.bind((hostIP, port))
while 1:
# Wait for either a connection, or a service stop request.
timeout = win32event.INFI NITE
waitHandles = self.hWaitStop, self.overlapped .hEvent
rc = win32event.Wait ForMultipleObje cts(waitHandles , 0, timeout)
if rc == win32event.WAIT _OBJECT_0:
# Stop event
break
else:
s.listen(5)
while True:
sessions = 0
qwinstaOut = os.popen(qwinst aCmd).readlines ()
for line in qwinstaOut:
## Look for active ICA sessions
if (((re.search("I CA", line, re.IGNORECASE)) :
sessions = sessions + 1
c, addr = s.accept()
## Send session count
c.send(str(sess ions))
c.close()
am trying to write a Windows service that will return the current
number of Citrix sessions to a client. This service will run on my
Citrix servers for usage tracking purposes.
The service itself seems to function properly, it starts, stops, logs
to the event viewer, etc. The problem seems to be with the portion
where it either waits to be stopped or waits for remote connection - it
does not get to the 'wait for remote connection' part.
If I remove the 'wait for stop request' portion the service will return
the session count but of course I can't stop the service nicely.
Does anyone have some example code I could take a look at or some
advice to get me back on track?
thanks in advance,
John
s = socket.socket()
hostIP = socket.gethostb yaddr(socket.ge thostname())[2][0]
if debug == 'true': servicemanager. LogInfoMsg('Hos t IP: ' +
str(hostIP))
s.bind((hostIP, port))
while 1:
# Wait for either a connection, or a service stop request.
timeout = win32event.INFI NITE
waitHandles = self.hWaitStop, self.overlapped .hEvent
rc = win32event.Wait ForMultipleObje cts(waitHandles , 0, timeout)
if rc == win32event.WAIT _OBJECT_0:
# Stop event
break
else:
s.listen(5)
while True:
sessions = 0
qwinstaOut = os.popen(qwinst aCmd).readlines ()
for line in qwinstaOut:
## Look for active ICA sessions
if (((re.search("I CA", line, re.IGNORECASE)) :
sessions = sessions + 1
c, addr = s.accept()
## Send session count
c.send(str(sess ions))
c.close()
Comment