Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 2 Jahren, 3 Monaten
Letzter Beitrag:
vor 2 Jahren, 3 Monaten
Beteiligte Autoren:
Yaku, Arie

[WD20]Background Service Executable[SOLVED]

Startbeitrag von Yaku am 11.11.2015 09:12

Hi all,
I'm trying to create a simple background service that just waits for a socket connection from a client, accepts it and creates a thread for listening purposes to that client.
Using the Debug Mode of windev makes it work like a charm, never skips a beat, but when i try to run the executable, after creating it through the wizard, it automatically goes to the closing event of the service, without even passing once in the "Running the service of NameOfMyService", which is the main event. Below there's the code that i wrote:

//initializing ServiceHelloWorld
CONSTANT
SName = "ServerRF"
Port = 2100
END
IF SocketCreate(SName,Port) THEN
SocketChangeTransmissionMode(SName,SocketNoEndTag)
ELSE
EndProgram("Errore di attivazione connessione")
END


//Running the service of ServiceHelloWorld
IF SocketWaitForConnection(SName) THEN
channel is string
channel = SocketAccept(SName)
IF channel "" THEN
ThreadExecute(channel,threadNormal,WaitMessage,channel)
ELSE
Error(ErrorInfo())
END
END

Have i done something stupid? If so, sorry, i'm a newbie about services, so any help would be VERY appreciated

Antworten:

Re: [WD20]Background Service Executable

Yaku,

I would add an WHEN_EXCEPTION around the code you mentioned.
And use ServiceWriteEventLog() to see the exception message in the window event logs.

Maybe there is some info there already, done by the Windev framework?

von Arie - am 11.11.2015 09:19

Re: [WD20]Background Service Executable

Hi Arie,
I've tried to add these lines of code that i've taken from the example provided by Windev:

WHEN EXCEPTION
ServiceWriteEventLog(ExceptionInfo,elError)
END

I've tried to place them at the beginning of the init of the project, at the beginning of the loop event, and even in both cases, but the result remains the same, it just jumps over the loop event...
Tried also to look into the "event register" of windows, and no mentioning of my service.
Maybe i'm doing something wrong with the wizard for the exe?

von Yaku - am 11.11.2015 09:32

Re: [WD20]Background Service Executable

Yaku,
are you sure it is running in the first place?
Can you start and stop the service from services.msc

I have a service running and took the service-example as a base for mine.
c:\WinDev 19 32\Examples\Training\WD Service\
Maybe you can try that one first to see what happens?

von Arie - am 11.11.2015 10:06
Arie,
Yeah, you were right, i've stupidly tried to run the exe straight away instead of installing it first...so, after creating the setup and running it, the service kinda works.
Thank you so much!

von Yaku - am 11.11.2015 10:18
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.