/// <summary>
        /// Sets the connection to specified box module (<c>otherModule</c>)
        /// in specified socket (<c>socketName</c>).
        /// </summary>
        /// <param name="socketName">Name of the socket.</param>
        /// <param name="otherModule">The other module.</param>
        /// <param name="__current">The Ice.Current.</param>
        /// <exception cref="T:Ferda.Modules.NameNotExistError">
        /// Thrown if socket named <c>socketName</c> doesn`t exist in the box module.
        /// </exception>
        /// <exception cref="T:Ferda.Modules.BadTypeError">
        /// Thrown if the type of functions provided by 
        /// the <c>otherModule</c> is not accepted by the socket.
        /// </exception>
        /// <exception cref="T:Ferda.Modules.ConnectionExistsError">
        /// Thrown if the socket accept only one connection and it is already used.
        /// </exception>
        public override void setConnection(string socketName, BoxModulePrx otherModule, Ice.Current __current)
        {
            // tests specified socketName existence
            if (!this.boxInfo.TestSocketNameExistence(socketName))
            {
                throw Ferda.Modules.Exceptions.NameNotExistError(null, null, "BMI21", socketName);
            }

            // tests Ferda.Modules.BoxType of otherModule
            bool badTypeError = true;
            Ice.ObjectPrx objPrx = otherModule.getFunctions();
            SocketInfo[] otherModuleSocketInfos = otherModule.getMyFactory().getSockets();
            foreach (BoxType socketBoxType in
                this.boxInfo.GetSocketTypes(socketName))
            {
                // tests otherModule`s functions type (functionsPrx.ice_isA)
                // tests if otherModule has needed sockets
                if (hasBoxType(socketBoxType, objPrx, otherModuleSocketInfos))
                {
                    badTypeError = false;
                    break;
                }
            }
            if (badTypeError)
            {
                // type of otherModule`s functions is bad
                Debug.WriteLine("BMI22");
                throw new Ferda.Modules.BadTypeError();
            }

            string identity = Ice.Util.identityToString(otherModule.ice_getIdentity());

            lock (this)
            {
                // the socket is actually property (i.e. value of the property is set by its socket)
                if (boxInfo.TestPropertyNameExistence(socketName))
                {
                    properties.Remove(socketName);
                }
                else
                {
                    // tests if socket (accepting only one connection) is already full
                    if ((!this.boxInfo.IsSocketMoreThanOne(socketName)) &&
                        this.connections[socketName].Count != 0)
                    {
                        // the socket is already used -> exception is thrown
                        Debug.WriteLine("BMI23");
                        throw new ConnectionExistsError();
                    }
                }
                this.connections[socketName][identity] = otherModule;
            }
        }
 /// <summary>
 /// Adds <see cref="T:Ferda.ModulesManager.BoxModule"/> to internal collection of boxes
 /// </summary>
 /// <param name="box">A <see cref="T:Ferda.ModulesManager.BoxModule"/></param>
 /// <param name="proxy">A <see cref="T:Ferda.Modules.BoxModulePrx"/></param>
 protected internal void addBoxModuleWithProxy(Ferda.ModulesManager.BoxModule box, BoxModulePrx proxy)
 {
     boxModuleByProxyIdentity[proxy.ice_getIdentity()]=box;
 }
 /// <summary>
 /// Removes <see cref="T:Ferda.ModulesManager.BoxModule"/> from
 /// internal collection of boxes.
 /// </summary>
 /// <param name="proxy">A <see cref="T:Ferda.Modules.BoxModulePrx"/></param>
 protected internal void removeBoxModuleWithProxy(BoxModulePrx proxy)
 {
     boxModuleByProxyIdentity.Remove(proxy.ice_getIdentity());
 }
 /// <summary>
 /// Gets <see cref="T:Ferda.ModulesManager.BoxModule"/>
 /// by <see cref="T:Ferda.Modules.BoxModulePrx"/>.
 /// </summary>
 /// <returns>A <see cref="T:Ferda.ModulesManager.BoxModule"/></returns>
 /// <param name="proxy">A <see cref="T:Ferda.Modules.BoxModulePrx"/></param>
 protected internal Ferda.ModulesManager.BoxModule getBoxModuleByProxy(BoxModulePrx proxy)
 {
     return boxModuleByProxyIdentity[proxy.ice_getIdentity()];
 }