NetProg

 


   

NETPROG  PRESENTATION

 

  OverView
  Functionalities
  Programming
API
C Examples
  Download
MXAddEndingProcedure C NetProg Library 


#include "mx.h"
int MXAddEndingProcedure (MXCom* pcom, int (*funct)(MXCom* pcom, void* applicationfield), void* applicationfield)


Parameters Description
pcom  the connection instance
funct  the function to call when  the connection is closed 
applicationfield  Programmer-specified data sent to the callback function


Description : 

This function adds a callback to the connection instance pcom. The callback is triggered when the connection instance pcom is closed.

If an error occurs on the connection  the MX manager automatically calls the callback funct  and closes the connection

applicationfield specifies the argument that is to be passed to the specified procedure when it is invoked


Return Values :  if error -1 else returns a value > 0


See Also : MXRemoveEndingProcedure, MXAddConnectCallBack, MXRemoveConnectCallBack, MXAddGeneralConnectCallBackMXRemoveGeneralConnectCallBack  


Example :

int OnCloseFile (MXCom* pcom, void* appfield)
{
  grConnexionFichier = MXOpenFile (pcom->MX, "MyFileName", "w", IOPROTO_STORE, 'D', 63);
  MXCloseCom (pcom->MX, grConnexionFichier);
  grConnexionFichier = NULL;
  return 1;
}



   ...

int main ()
{

  grConnexionFichier = MXOpenFile (pcom->MX, "MyFileName", "r", IOPROTO_STORE, 'D', 63);
  if (grConnexionFichier) 
  {
     MXMessage* pmessage;
     MXAddEndingProcedure (grConnexionFichier, OnCloseFile, NULL);
     while (pmessage = MXRecv (pcom->MX, grConnexionFichier))
     {
        MXPutThisMessage (pcom, pmessage);
        MXFreeMessage (pmessage);
     }
     MXCloseCom (pcom->MX, grConnexionFichier);
  }

  ...

}