Hello. This is a hard one for me to understand/solve.
Using synapse on delphi 11.
I have a main form that starts a thread (TTCPHttpDaemon) defined in a used Unit;
TTCPHttpDaemon.create;
The initialization section of the the blcksock.pas of sinapse, runs at the very beginning
of the App seems to successfully create the socket
synsock.WSAStartup(WinsockLevel, WsaDataOnce);
I create the thread (log_it() is a function to log messages).
TTCPHttpDaemon.Create;
TRY
inherited create(false);
sock:=TTCPBlockSocket.create;
FreeOnTerminate:=true;
except
on E:SysUtils.Exception do begin
log_it('TTCPHttpDaemon.Create '+e.message);
end;
end;
end;
No errors. Then right here i get the inexplicable behaviour
procedure TTCPHttpDaemon.Execute;
begin
with sock do begin
try
CreateSocket;
except
on E:SysUtils.Exception do begin
log_it(e.message);
end;
end;
bind(serverip,PORTNUMBER); //portno
listen;
repeat
try
b:= canread (1000); RIGHT HERE!!!!!
except
on E:SysUtils.Exception do begin
log_it('****** Canread error: '+e.message);
end;
end;
if b then
ClientSock:=sock.accept;
...................
on the canread() function the error is 'winsock not initialized' code:10093
And the main form is destroyed, by-passing the except block.
What goes wrong, where?
This happened suddenly without any change to the App that I could tell. Could it be one of the lates windows 10 updates?