341 return err; |
341 return err; |
342 } |
342 } |
343 |
343 |
344 TInt CSocketDesc::FinalClose() |
344 TInt CSocketDesc::FinalClose() |
345 { |
345 { |
346 RHeap* oheap = User::SwitchHeap(Backend()->Heap()); |
346 CLocalSystemInterface* backend = Backend(); |
|
347 backend->DefConnLock().Wait(); |
|
348 RHeap* oheap = User::SwitchHeap(backend->Heap()); |
347 if (iSocketPtr != NULL) |
349 if (iSocketPtr != NULL) |
348 { |
350 { |
349 iSocketPtr = NULL; |
351 iSocketPtr = NULL; |
350 StopInterface(NULL); // Checks for RConnection as well as RSubConnection |
352 StopInterface(NULL); // Checks for RConnection as well as RSubConnection |
|
353 backend->RemoveSocket(this); |
351 } |
354 } |
352 |
355 |
353 CSockDescBase::FinalClose(); |
356 CSockDescBase::FinalClose(); |
354 User::SwitchHeap(oheap); |
357 User::SwitchHeap(oheap); |
|
358 backend->DefConnLock().Signal(); |
355 return KErrNone; |
359 return KErrNone; |
356 } |
360 } |
357 |
361 |
358 |
362 |
359 void CSocketDesc::Read (TDes8& aBuf, TRequestStatus& aStatus) |
363 void CSocketDesc::Read (TDes8& aBuf, TRequestStatus& aStatus) |
1742 } |
1746 } |
1743 |
1747 |
1744 TInt CSocketDesc::OpenUsingPreference() |
1748 TInt CSocketDesc::OpenUsingPreference() |
1745 { |
1749 { |
1746 TInt ret = 0; |
1750 TInt ret = 0; |
1747 RConnection defConnection = Backend()->GetDefaultConnection(); |
1751 // Update when supporting INET6 |
1748 |
1752 TInt addrfamily = (iAddrFamily == AF_INET6 ? KAfInet : iAddrFamily); |
1749 if (iConnectionPtr != NULL) // iConnection initialized |
1753 if (iConnectionPtr != NULL) // iConnection initialized |
1750 { |
1754 { |
1751 if (iAddrFamily == AF_INET6) |
1755 ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol,iConnection); |
1752 { |
|
1753 ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol,iConnection); |
|
1754 } |
|
1755 else |
|
1756 { |
|
1757 ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol,iConnection); |
|
1758 } |
|
1759 } |
1756 } |
1760 else if (iSubConnectionPtr != NULL) // iSubConnection initialized |
1757 else if (iSubConnectionPtr != NULL) // iSubConnection initialized |
1761 { |
1758 { |
1762 if (iAddrFamily == AF_INET6) |
1759 ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol,iSubConnection); |
1763 { |
1760 } |
1764 ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol,iSubConnection); |
1761 else |
1765 } |
1762 { |
1766 else |
1763 RConnection& defConnection = Backend()->GetDefaultConnection(); |
1767 { |
1764 //Now check if the default connection is intialized. This is given lesser |
1768 ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol,iSubConnection); |
1765 //priority than the socket specific preferences checked above. |
1769 } |
1766 if(defConnection.SubSessionHandle() != 0) |
1770 } |
1767 { |
1771 //Now check if the default connection is intialized. This is given lesser |
1768 ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol,defConnection); |
1772 //priority than the socket specific preferences checked above. |
1769 if (!ret) |
1773 else if(defConnection.SubSessionHandle() != 0) |
1770 { |
1774 { |
1771 Backend()->AddSocket(this); |
1775 if (iAddrFamily == AF_INET6) |
1772 } |
1776 { |
1773 } |
1777 ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol,defConnection); |
1774 else // No connection preference is set |
1778 } |
1775 { |
1779 else |
1776 ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol); |
1780 { |
1777 } |
1781 ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol,defConnection); |
1778 } |
1782 } |
1779 |
1783 } |
|
1784 else // No connection preference is set |
|
1785 { |
|
1786 if (iAddrFamily == AF_INET6) |
|
1787 { |
|
1788 ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol); |
|
1789 } |
|
1790 else |
|
1791 { |
|
1792 ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol); |
|
1793 } |
|
1794 } |
|
1795 if(KErrNone == ret) |
1780 if(KErrNone == ret) |
1796 { |
1781 { |
1797 iSocketPtr = &iSocket; |
1782 iSocketPtr = &iSocket; |
1798 } |
1783 } |
1799 iConnectInProgress = EFalse; |
1784 iConnectInProgress = EFalse; |
1800 return ret; |
1785 return ret; |
1801 } |
1786 } |
|
1787 |
|
1788 void CSocketDesc::TempClose() |
|
1789 { |
|
1790 if (iSocket.SubSessionHandle() != 0) |
|
1791 { |
|
1792 iSocketPtr = NULL; |
|
1793 iSocket.CancelAll(); |
|
1794 TRequestStatus status; |
|
1795 iSocket.Shutdown(RSocket::EImmediate, status); |
|
1796 User::WaitForRequest(status); |
|
1797 iSocket.Close(); |
|
1798 } |
|
1799 } |
1802 |
1800 |
1803 void CSocketDesc::AccessPointListL(CArrayFixFlat<TAccessPointRecord> *&aRecordPtr, |
1801 void CSocketDesc::AccessPointListL(CArrayFixFlat<TAccessPointRecord> *&aRecordPtr, |
1804 TInt &aCount) |
1802 TInt &aCount) |
1805 { |
1803 { |
1806 TAccessPointRecord tempRecord; |
1804 TAccessPointRecord tempRecord; |