Hello Bevan,
Thanks for your time. Please find below the server code. Like i said, i don't really handle the clients since TWSocketServer manage it. What i understand is that the stack overflow is now well handled because after the callback OnClientBGException the program continue to work. But now, after about five seconds i receive an Access Violation in the line 16233 of OverbyteIcsWSocket.pas : the line focused by the debugger is the procedure Do_FD_FWRITE of the TCustomSslWSocket, by i do not use any SSL option. procedure TCustomSslWSocket.Do_FD_WRITE(var Msg: TMessage); So why does the server call a procedure from SSL even if i do not use SSL ? I read different example and i really don't see what can i do much more ! The try catch is enclosed on the WriteFrame call like that : Try{ mpServerSocketEngine->WriteFrame(< Hello > ) ; }catch(.) { } class TServerSocketEngine { protected: int mHostPort; TWSocketServer* mpWSocketServer; void __fastcall ClientConnect(TObject *Sender, TWSocketClient *Client, WORD Error); void __fastcall ClientDisconnect(TObject *Sender, TWSocketClient *Client, WORD Error); void __fastcall ClientBgException(TObject *Sender, Exception *E, bool &CanClose); void __fastcall WSocketServer1BgException(TObject *Sender, Exception *E, bool &CanClose); public: TServerSocketEngine(); //---initialisation bool Connect(); bool WriteFrame(const AnsiString &frame); bool WriteFlush(); }; TServerSocketEngine::TServerSocketEngine() { mConnected = false; mHostPort = 7000; mpWSocketServer = TWSocketServer* = new TWSocketServer(NULL); mpWSocketServer->Banner = ""; mpWSocketServer->OnClientConnect = ClientConnect; mpWSocketServer->OnClientDisconnect = ClientDisconnect; mpWSocketServer->OnBgException = WSocketServer1BgException; mpWSocketServer->SslEnable = false; mpWSocketServer->MaxClients = 32; } void __fastcall TServerSocketEngine::ClientConnect(TObject *Sender, TWSocketClient *Client, WORD Error) { Client->OnBgException = ClientBgException; Client->SslEnable = false; } void __fastcall TServerSocketEngine::ClientDisconnect(TObject *Sender, TWSocketClient *Client, WORD Error) { } // This event handler is called when a client socket experience a background // exception. It is likely to occurs when client aborted connection and data // has not been sent yet. void __fastcall TServerSocketEngine::WSocketServer1BgException(TObject *Sender, Exception *E, bool &CanClose) { CanClose = FALSE; // Hoping that server will still work ! } void __fastcall TServerSocketEngine::ClientBgException(TObject *Sender, Exception *E, bool &CanClose) { CanClose = TRUE; // Goodbye client ! } bool TServerSocketEngine::Connect() { if (mHostPort == 0) return false; try { mpWSocketServer->Addr = "0.0.0.0"; mpWSocketServer->Port = mHostPort; mpWSocketServer->Proto = "tcp"; mpWSocketServer->Listen(); mConnected = true; } catch (...) { return false; } return true; } bool TServerSocketEngine::WriteFrame(const AnsiString &frame) { for (int i = 0; i < mpWSocketServer->ClientCount; i++) { if(mpWSocketServer->Client[i] == NULL) continue; if(mpWSocketServer->Client[i]->LastError > 0) { continue; } mpWSocketServer->Client[i]->SendStr(String(frame.c_str())); } return true; } bool TServerSocketEngine::WriteFlush() { for (int i = 0; i < mpWSocketServer->ClientCount; i++) { if(mpWSocketServer->Client[i] == NULL) continue; mpWSocketServer->Client[i]->Flush(); } return true; } -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be