Crash on ServerSocket.CanRead() lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Ocye · 2014-01-18 21:21 I'm using Synapse for Client/Server communication via TCP/IP. All works well but one user reports problems on Bodhi Linux (with Enlightment desktop). He or she cannot connect to a local server but is able to connect to a foreign server. With some debug messages we tracked down the issue to CanRead() when data is available, that means when a client tries to connect. Code: [Select]    procedure TCustomTCPServer.Execute; begin   FServerSocket.Bind('0.0.0.0', FPort);   //FServerSocket.SetLinger(true, 10);   if FServerSocket.LastError=0 then   begin     FServerSocket.Listen;     FRecvMsg.Clear;     while not Terminated do     begin write('A');       if FServerSocket.CanRead(100) then       begin write(0);         aSocket:=FServerSocket.Accept; write(1);         aSender:=TClient.Create(aSocket, FClients);         aSender.GroupID:=NextGroupId;         aSender.OnLog:=@Log;         FClients.Add(aSender);       end; write('B'); ... Output should be ABA01B but is ABA-crash, that is when CanRead() has data. The error message says "Fatal IO error 11 (Ressource temporairement non disponible) on X server :0.0." I run Bodhi myself within a VB and had no problems to connect. Of course it works well with all other OS. And the user reports no problems connecting to another, non-local server. Does anyone have an idea about the reason and how to solve this issue? ---------------------------------------------------------------------- Ocye · 2014-01-19 18:56 After binding to localhost instead of 0.0.0.0 the error message points to other problems: [xcb] Unknown sequence number while processing reply [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. I have no idea how to solve it. ---------------------------------------------------------------------- User137 · 2014-01-20 03:12 Have you added "cthreads" in the uses list where synapse threads are used? It is required for linux. Also you might not need to call CanRead() in the listener thread. ---------------------------------------------------------------------- Ocye · 2014-01-20 06:33 Good idea. But of course, cthreads is included. The same code is run on the dedicated server too (to that server the user can connect as client). I use a TLIst for all connected clients (aka blocksockets with some additional information) and distribute messages. The distribution depends on the kind of server, either local with only a few options or non-local with all features, for instance higscore calculation. Actually its a game server that can be run as local server/client connection. The user reports problems when a client connects to the server.