Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1390
  • Last Modified:

Sockets Error (Borland C++ Builder)

Asynchronous socket error...

this is what happens if i close the cleint without calling Close ( ) of the client socket... this will bring up a nasty popup in the server which will cause the server to stop working!!!

I NEED TO GET RID of the stupid window, i can write my own error handlers that are much better and dont hang the program (setting the onclienterror does not work)
0
Fearum
Asked:
Fearum
1 Solution
 
thienpnguyenCommented:
1/ For TServerSocket

     Set the ErrorCode parameter to 0 if the OnClientError event
handler successfully deals with the error condition to prevent
an ESocketError from being thrown.

        void __fastcall TForm1::ServerSocket1ClientError(TObject *Sender,
             TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
       {
             if( ErrorCode )
             {
                    // process ...
                    // .....
     
                    ErrorCode = 0; //  to prevent an ESocketError from being thrown
             }
       }



2/ For TClientSocket

      Write an OnError event handler to respond to errors that arise
with the socket connection. Set the ErrorCode parameter to 0 if the
OnError event handler successfully deals with the error condition,
to prevent an ESocketError from being thrown.


       void __fastcall TForm1::ClientSocket1Error(TObject *Sender,
             TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
       {
              if( ErrorCode )
              {
                     // process ....
                     // ......

                     ErrorCode = 0; //  to prevent an ESocketError from being thrown
               }
       }


}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now