internal CRNode m_pRNode; // node information for UDT list used in rcv queue #endregion #region constructor and desctructor CUDT(CUDT ancestor) { m_pSndBuffer = null; m_pRcvBuffer = null; m_pSndLossList = null; m_pRcvLossList = null; m_pACKWindow = null; m_pSndTimeWindow = null; m_pRcvTimeWindow = null; m_pSndQueue = null; m_pRcvQueue = null; m_pPeerAddr = null; m_pSNode = null; m_pRNode = null; // Initilize mutex and condition variables initSynch(); // Default UDT configurations m_iMSS = ancestor.m_iMSS; m_bSynSending = ancestor.m_bSynSending; m_bSynRecving = ancestor.m_bSynRecving; m_iFlightFlagSize = ancestor.m_iFlightFlagSize; m_iSndBufSize = ancestor.m_iSndBufSize; m_iRcvBufSize = ancestor.m_iRcvBufSize; m_Linger = ancestor.m_Linger; m_iUDPSndBufSize = ancestor.m_iUDPSndBufSize; m_iUDPRcvBufSize = ancestor.m_iUDPRcvBufSize; m_iSockType = ancestor.m_iSockType; m_iIPversion = ancestor.m_iIPversion; m_bRendezvous = ancestor.m_bRendezvous; m_iSndTimeOut = ancestor.m_iSndTimeOut; m_iRcvTimeOut = ancestor.m_iRcvTimeOut; m_bReuseAddr = true; // this must be true, because all accepted sockets shared the same port with the listener m_llMaxBW = ancestor.m_llMaxBW; m_pCCFactory = ancestor.m_pCCFactory.clone(); m_pCC = null; m_pCache = ancestor.m_pCache; // Initial status m_bOpened = false; m_bListening = false; m_bConnected = false; m_bClosing = false; m_bShutdown = false; m_bBroken = false; }
internal CUDT() { // Initilize mutex and condition variables initSynch(); // Default UDT configurations m_iMSS = 1500; m_bSynSending = true; m_bSynRecving = true; m_iFlightFlagSize = 25600; m_iSndBufSize = 8192; m_iRcvBufSize = 8192; //Rcv buffer MUST NOT be bigger than Flight Flag size m_Linger = new LingerOption(1, 180); //m_Linger.l_onoff = 1; //m_Linger.l_linger = 180; m_iUDPSndBufSize = 65536; m_iUDPRcvBufSize = m_iRcvBufSize * m_iMSS; m_iIPversion = AF_INET; m_bRendezvous = false; m_iSndTimeOut = -1; m_iRcvTimeOut = -1; m_bReuseAddr = true; m_llMaxBW = -1; m_pCCFactory = new CCCFactory<CUDTCC>(); m_pCC = null; m_pCache = null; // Initial status m_bOpened = false; m_bListening = false; m_bConnected = false; m_bClosing = false; m_bShutdown = false; m_bBroken = false; }
// Functionality: // Configure UDT options. // Parameters: // 0) [in] optName: The enum name of a UDT option. // 1) [in] optval: The value to be set. // 2) [in] optlen: size of "optval". // Returned value: // None. void setOpt(UDTOpt optName, Object optval, int optlen) { CGuard cg = new CGuard(m_ConnectionLock); CGuard sendguard = new CGuard(m_SendLock); CGuard recvguard = new CGuard(m_RecvLock); switch (optName) { case UDTOpt.UDT_MSS: if (m_bOpened) throw new CUDTException(5, 1, 0); if ((int)optval < (int)(28 + sizeof(CHandShake))) throw new CUDTException(5, 3, 0); m_iMSS = (int)optval; // Packet size cannot be greater than UDP buffer size if (m_iMSS > m_iUDPSndBufSize) m_iMSS = m_iUDPSndBufSize; if (m_iMSS > m_iUDPRcvBufSize) m_iMSS = m_iUDPRcvBufSize; break; case UDTOpt.UDT_SNDSYN: m_bSynSending = (bool)optval; break; case UDTOpt.UDT_RCVSYN: m_bSynRecving = (bool)optval; break; case UDTOpt.UDT_CC: if (m_bConnected) throw new CUDTException(5, 1, 0); //if (null != m_pCCFactory) // delete m_pCCFactory; m_pCCFactory = ((CCCVirtualFactory )optval).clone(); break; case UDTOpt.UDT_FC: if (m_bConnected) throw new CUDTException(5, 2, 0); if (*(int*)optval < 1) throw new CUDTException(5, 3); // Mimimum recv flight flag size is 32 packets if (*(int*)optval > 32) m_iFlightFlagSize = *(int*)optval; else m_iFlightFlagSize = 32; break; case UDTOpt.UDT_SNDBUF: if (m_bOpened) throw new CUDTException(5, 1, 0); if (*(int*)optval <= 0) throw new CUDTException(5, 3, 0); m_iSndBufSize = *(int*)optval / (m_iMSS - 28); break; case UDTOpt.UDT_RCVBUF: if (m_bOpened) throw new CUDTException(5, 1, 0); if (*(int*)optval <= 0) throw new CUDTException(5, 3, 0); // Mimimum recv buffer size is 32 packets if (*(int*)optval > (m_iMSS - 28) * 32) m_iRcvBufSize = *(int*)optval / (m_iMSS - 28); else m_iRcvBufSize = 32; // recv buffer MUST not be greater than FC size if (m_iRcvBufSize > m_iFlightFlagSize) m_iRcvBufSize = m_iFlightFlagSize; break; case UDTOpt.UDT_LINGER: m_Linger = *(linger*)optval; break; case UDTOpt.UDP_SNDBUF: if (m_bOpened) throw new CUDTException(5, 1, 0); m_iUDPSndBufSize = *(int*)optval; if (m_iUDPSndBufSize < m_iMSS) m_iUDPSndBufSize = m_iMSS; break; case UDTOpt.UDP_RCVBUF: if (m_bOpened) throw new CUDTException(5, 1, 0); m_iUDPRcvBufSize = *(int*)optval; if (m_iUDPRcvBufSize < m_iMSS) m_iUDPRcvBufSize = m_iMSS; break; case UDTOpt.UDT_RENDEZVOUS: if (m_bConnected) throw new CUDTException(5, 1, 0); m_bRendezvous = *(bool *)optval; break; case UDTOpt.UDT_SNDTIMEO: m_iSndTimeOut = *(int*)optval; break; case UDTOpt.UDT_RCVTIMEO: m_iRcvTimeOut = *(int*)optval; break; case UDTOpt.UDT_REUSEADDR: if (m_bOpened) throw new CUDTException(5, 1, 0); m_bReuseAddr = *(bool*)optval; break; case UDTOpt.UDT_MAXBW: if (m_bConnected) throw new CUDTException(5, 1, 0); m_llMaxBW = *(Int64*)optval; break; default: throw new CUDTException(5, 0, 0); } }