[Synapse] how to interrupt RecvPacket? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- undeadorc · 2014-06-19 18:21 Hello! I'm using Synapse for UDP networking (simple TThread based class). If I use RecvPacket without timeout (-1) in Execute procedure, something like this: Code: [Select] procedure TUDPServer.Execute; var szBuffer: string;     i: Integer;     nCount: Integer; begin   m_pLogger.Info('UDPServer local port = %s', [Port]);   m_pSocket.Bind(cAnyHost, Port );   nCount := 0;   if (m_pSocket.LastError = 0) then   begin     while True do     begin       if Terminated then Break;       szBuffer := m_pSocket.RecvPacket(-1);       if m_pSocket.LastError = 0 then       begin         m_fuOnReceive(szBuffer, m_pSocket.GetRemoteSinIP, m_pSocket.GetRemoteSinPort);         WriteLn(m_pSocket.GetRemoteSinIP, ':', m_pSocket.GetRemoteSinPort);       end;     end;   end; end; Then I can't destroy and free TUDPServer, coz RecvPacket(-1) is waiting for incoming data. How can I interrupt this waiting? Or maybe I do something wrong and there is other way to code UDP server without timeout? ---------------------------------------------------------------------- User137 · 2014-06-19 20:22 This does the trick? Code: [Select]m_pSocket.AbortSocket;Maybe .CloseSocket; . ---------------------------------------------------------------------- undeadorc · 2014-06-20 19:17 Thanks, both are good! CloseSocket executes AbortSocket.