PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD22] Socket question
[WD22] Socket question
Iniciado por guest, 25,jun. 2018 19:39 - 2 respuestas
Publicado el 25,junio 2018 - 19:39
Hi,

this is the first time for me that I have to use sockets. I have some problems to understand the read / write mechanism.

What I do now:

1. Socketread in a thread with:
Myresult=socketread("Mysocket1", true)

2. socketwrite("Mysocket2",blabla)

How can I transfer Myresult in the main thread (I now use a global variable) ?
How can I secure end the socketread ? The parameter says "waiting forever ...."

Has anybody a simple example for me ? The PC Soft examples are to complicated for me.
Publicado el 25,junio 2018 - 23:19
Hi Michael

there are 2 examples for sockets management, one for one on one communication, and one for one to many...

Bother are the simplest possible implementation for each case...

So start with the one on one and try to understand it... THEN look at the one to many.

Best regards
Publicado el 27,junio 2018 - 11:52
OK,

I looked at the examples.

In my special way the

LOOP
IF EventWait("TERM",5) THEN BREAK
gsEmpfangsstring=SocketRead("DesiteReceive",false,10)
ThreadPause(1)
END

doesn´t read the message from the client, only the

gsEmpfangsstring=SocketRead("DesiteReceive",true)

read it. But so I can´t close the thread and the port is sometimes in use, so that only a reboot helps.
How can I reset a occupied socket-port in windev ? Scocketclose ends with an error (port is used in another program), but how can a closed windev program occupied a port ?