internal void ConnectoToPublication(DPE_PublicationConnectionHandler_Type connectionHandlerType, string publicationName, DPE_ServerDefs.DPE_PublicationConnectionMode connectionMode)
            {
                //*****************************************************************************
                //request to the server the connection parameters of the publication
                P2PDataRequest dataREquest = new P2PDataRequest(DPE_ServerDefs.DPE_CMD_PUBLICATION_SUBSCRIPTION_DATA);

                dataREquest.AddRequestParameter(DPE_PublicationsDefinitions.DPE_PUBLICATION_NAME, publicationName);

                P2PData publicationPArams = null;
                string  msg = "";

                Services.P2PCommunicationsScheme.P2PPortClient publicationsInformationRetrieveP2PPortClient = null;
                int trialsCount = 0;


                publicationsInformationRetrieveP2PPortClient = new Services.P2PCommunicationsScheme.P2PPortClient(this._STXDataSocketClient.DSSServerHostName, this._STXDataSocketClient.PublicationsInformationRetrieve_PortNumber);
                publicationsInformationRetrieveP2PPortClient.Connect();


                //performs a  while cycle until the client gets the connection parameters
                while (true)
                {
                    try
                    {
                        publicationPArams = publicationsInformationRetrieveP2PPortClient.RetrieveData(dataREquest);
                        break;
                    }
                    catch (Exception ex)
                    {
                        trialsCount++;

                        if (trialsCount >= MAX_DATA_CONNECTION_PARAMETERS_INQUIRY_TRIALS)
                        {
                            msg = "Error trying to connect to publication \'" + publicationName + "\': " + ex.Message;
                            throw (new Exception(msg));
                        }
                    }

                    System.Threading.Thread.Sleep(10);
                }

                try
                {
                    publicationsInformationRetrieveP2PPortClient.Dispose();
                }
                catch (Exception)
                {
                }

                CustomHashTable paramsList          = (CustomHashTable)publicationPArams.Value;
                string          publicationHostNAme = System.Convert.ToString(paramsList.Item(DPE_PublicationsDefinitions.DPE_PUBLICATION_HOSTNAME));
                int             publicationPort     = System.Convert.ToInt32(paramsList.Item(DPE_PublicationsDefinitions.DPE_PUBLICATION_PORT));

                //*****************************************************************************
                //CREATION OF THE PUBLICATION HANDLER and CONNECTION WITH publication
                DPE_PublicationConnectionHandler publicationConnectionHandler = default(DPE_PublicationConnectionHandler);

                publicationConnectionHandler = this.CreatePublicationConnectionHandler(connectionHandlerType, this._STXDataSocketClient, publicationName, publicationHostNAme, publicationPort, connectionMode);


                //*****************************************************************************
                //Ciclic process in order to allow the server to register the client socket connection . -> to synchronize the client registration
                //by ser client with the server event to log the publication event

                msg = "Error trying to perform the client connection registration to the publication \'" + publicationName + "\' : ";

                //*****************************************************************************
                //registration of the client connection to a publication in the server
                //the client sends to the server a information telling to which publication has already connected
                //and also for the TCP client mode to tell the publication to which port send the data

                int  connectionRegistrationTrialCounter = 0;
                bool connectionRegistration             = false;

                //preparation of the connection information into a p2p data
                P2PData clientPubCnnData = new P2PData(DPE_ServerDefs.DPE_CMD_CLIENT_PUBLICATION_CONNECTION_REGISTRATION, DPE_ServerDefs.DPE_CMD_CLIENT_PUBLICATION_CONNECTION_REGISTRATION);

                clientPubCnnData.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_CLIENT_ID, this._STXDataSocketClient.ClientID);
                clientPubCnnData.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATION_NAME, publicationName);
                clientPubCnnData.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATION_CONNECTION_HANDLER_ID, publicationConnectionHandler.HandlerID);
                //---------------------HANDLING FOR THE CONNECTION MODE ------------------------------
                string connectionModeAsString = "";

                connectionModeAsString = DPE_ServerDefs.Get_STXDSS_PublicationConnectionMode_ToAString(connectionMode);
                clientPubCnnData.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATION_CLIENT_CONNECTION_MODE, connectionModeAsString);


                msg = "Error trying to perform the client connection registration to the publication \'" + publicationName + "\' : ";


                //sends to server the information to the server several times until the information reaches the server
                Services.P2PCommunicationsScheme.P2PPortClient publicationsClientRegistrationP2PPortClient = default(Services.P2PCommunicationsScheme.P2PPortClient);

                publicationsClientRegistrationP2PPortClient = new Services.P2PCommunicationsScheme.P2PPortClient(this._STXDataSocketClient.DSSServerHostName, this._STXDataSocketClient.PublicationsClientRegistration_PortNumber);
                publicationsClientRegistrationP2PPortClient.Connect();

                while (connectionRegistration == false)
                {
                    try
                    {
                        publicationsClientRegistrationP2PPortClient.SendData(P2PDataSendMode.SyncrhonicalSend, clientPubCnnData);

                        connectionRegistration = true;

                        publicationsClientRegistrationP2PPortClient.Dispose();

                        CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, "Connection to publication \'" + publicationName + "\' succesfull");

                        break;
                    }
                    catch (Exception ex)
                    {
                        System.Threading.Thread.Sleep(10);

                        connectionRegistrationTrialCounter++;

                        if (connectionRegistrationTrialCounter >= MAX_CONNECTION_REGISTRATION_TRIALS)
                        {
                            msg = msg + ex.Message;

                            try
                            {
                                publicationsClientRegistrationP2PPortClient.Dispose();
                            }
                            catch (Exception)
                            {
                            }

                            try
                            {
                                this.DisposeConnectionHandler(publicationName);
                            }
                            catch (Exception)
                            {
                            }

                            throw (new Exception(msg));
                        }
                    }
                }
            }