datacommsserver/esockserver/eintsock/ss_eintsock.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // eintsock.cpp
       
    15 // Implementation of forwarding methods for internal sockets
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #include "ss_eintsocklog.h"
       
    25 #include <comms-infras/eintsock.h>
       
    26 #include <comms-infras/ss_common.h>
       
    27 #include <comms-infras/ss_nodemessages.h>
       
    28 #include <comms-infras/ss_nodemessages_dataclient.h>
       
    29 #include <comms-infras/ss_thread.h>
       
    30 #include "ss_eintsockimpl.h"
       
    31 #include "ss_eintsock_msgs.h"
       
    32 #include <ss_glob.h>
       
    33 #include <comms-infras/sockmes.h>
       
    34 
       
    35 using namespace ESock;
       
    36 using namespace CommsFW;
       
    37 using namespace Messages;
       
    38 
       
    39 EXPORT_C RInternalSocket::RInternalSocket()
       
    40 : iImplementation(NULL)
       
    41 	{
       
    42     }
       
    43 
       
    44 EXPORT_C RInternalSocket::~RInternalSocket()
       
    45 	{
       
    46     }
       
    47 
       
    48 EXPORT_C TInt RInternalSocket::Open()
       
    49 /**
       
    50 Special Open() for this class to mimic RSocket, but without the socket server session being required
       
    51 @see RSocket documentation
       
    52 */
       
    53 	{
       
    54 	__ASSERT_DEBUG(!iImplementation, InternalSocketPanic(ENotNullSocket));
       
    55 	LOG(Log::Printf(_L("RIS::Open()")));
       
    56 
       
    57 	TWorkerId selfWorkerId;
       
    58 	TInt ret = CWorkerThread::CurrentWorkerId(selfWorkerId);
       
    59 	if(ret == KErrNone)
       
    60 		{
       
    61 		TNodeId serverCookie;
       
    62 		ret = CWorkerThread::CookieForWorkerId(selfWorkerId, serverCookie);
       
    63 		if(ret == KErrNone)
       
    64 			{
       
    65 			MCommsTransportSender* sender = &static_cast<MCommsTransportSender&>(TlsGlobals::Get().TransportSender());
       
    66 			TEIntSockOpMsgWrapper opMsg;
       
    67 			TEIntSockMsgExt openMsg(ESoCreateNull, opMsg, iImplementation, sender, serverCookie);
       
    68 			ret = CInternalSockSubSession::SendReceiveMsg(openMsg, sender, serverCookie);
       
    69 			}
       
    70 		}
       
    71 	LOG(Log::Printf(_L("RIS::Open() ret=%d impl=%08x"), ret, iImplementation));
       
    72 	return ret;
       
    73 	}
       
    74 
       
    75 EXPORT_C TInt RInternalSocket::Open(const TDesC& aName)
       
    76 /**
       
    77 Special Open() for this class to mimic RSocket, but without the socket server session being required
       
    78 With the asynchronous nature of COMMS FW this API might cause deadlock scenario, hence this API is deprecated 
       
    79 and asynchrnous version is provided. 
       
    80 
       
    81 @see RInternalSocket::Open(const TDesC& aName, TRequestStatus& aStatus)
       
    82 
       
    83 @deprecated from 9.5
       
    84 @see RSocket documentation
       
    85 */
       
    86 	{
       
    87 	__ASSERT_DEBUG(!iImplementation, InternalSocketPanic(ENotNullSocket));
       
    88 	LOG(Log::Printf(_L("RIS::Open(%S)"), &aName));
       
    89 	
       
    90 	TNodeId serverCookie;
       
    91 	TInt ret = CWorkerThread::CookieForProtocolByName(aName, serverCookie);
       
    92 	if(ret == KErrNone)
       
    93 		{
       
    94 		MCommsTransportSender* sender = &static_cast<MCommsTransportSender&>(TlsGlobals::Get().TransportSender());
       
    95 		TEIntSockOpMsgWrapper opMsg (&aName);
       
    96 		TEIntSockMsgExt openMsg((TSockMess)KSoOpenByName, opMsg, iImplementation, sender, serverCookie);
       
    97 		ret = CInternalSockSubSession::SendReceiveMsgAsync(openMsg, sender, serverCookie);
       
    98 		}
       
    99 	LOG(Log::Printf(_L("RIS::Open(%S)=%d impl=%08x"), &aName, ret, iImplementation));
       
   100 	return ret;
       
   101 	}
       
   102 
       
   103 EXPORT_C TInt RInternalSocket::Open(TUint aAddrFamily,TUint aSockType,TUint aProtocol)
       
   104 /**
       
   105 Special Open() for this class to mimic RSocket, but without the socket server session being required
       
   106 With the asynchronous nature of COMMS FW this API might cause deadlock scenario, hence this API is deprecated 
       
   107 and asynchrnous version is provided. 
       
   108 
       
   109 @see RInternalSocket::Open(TUint aAddrFamily,TUint aSockType,TUint aProtocol, TRequestStatus& aStatus)
       
   110 
       
   111 @see RSocket documentation
       
   112 */
       
   113 	{
       
   114 	__ASSERT_DEBUG(!iImplementation, InternalSocketPanic(ENotNullSocket));
       
   115 	LOG(Log::Printf(_L("RIS::Open(%d, %d, %d)"), aAddrFamily, aSockType, aProtocol));
       
   116 	
       
   117 	TNodeId serverCookie;
       
   118 	TInt ret = CWorkerThread::CookieForProtocol(aAddrFamily, aSockType, aProtocol, serverCookie);
       
   119 	if(ret == KErrNone)
       
   120 		{
       
   121 		MCommsTransportSender* sender = &static_cast<MCommsTransportSender&>(TlsGlobals::Get().TransportSender());
       
   122 		TEIntSockOpMsgWrapper opMsg (aAddrFamily, aSockType, aProtocol);
       
   123 		TEIntSockMsgExt openMsg(ESoCreate, opMsg, iImplementation, sender, serverCookie);		
       
   124 		ret = CInternalSockSubSession::SendReceiveMsgAsync(openMsg, sender, serverCookie);
       
   125 		}
       
   126 	LOG(Log::Printf(_L("RIS::Open(%d, %d, %d)=%d impl=%08x"), aAddrFamily, aSockType, aProtocol, ret, iImplementation));
       
   127 	return ret;
       
   128 	}
       
   129 
       
   130 EXPORT_C void RInternalSocket::Open( const TDesC& aName, TRequestStatus& aStatus )
       
   131 	{
       
   132 	__ASSERT_DEBUG(!iImplementation, InternalSocketPanic(ENotNullSocket));
       
   133 	LOG(Log::Printf(_L("RIS::Open(%S)"), &aName));
       
   134 	
       
   135 	aStatus = KRequestPending;
       
   136 	
       
   137 	TNodeId serverCookie;
       
   138 	TInt ret = CWorkerThread::CookieForProtocolByName(aName, serverCookie);
       
   139 	if(ret == KErrNone)
       
   140 		{
       
   141 		MCommsTransportSender* sender = &static_cast<MCommsTransportSender&>(TlsGlobals::Get().TransportSender());
       
   142 		TEIntSockOpMsgWrapper opMsg (&aName);		
       
   143 		TEIntSockMsgExt openMsg((TSockMess)KSoOpenByName, opMsg, iImplementation, aStatus, sender, serverCookie);
       
   144 		CInternalSockSubSession::SendMsg(openMsg, sender, serverCookie);
       
   145 		}
       
   146 	else
       
   147 		{
       
   148 		TRequestStatus* pStatus = &aStatus;
       
   149 		User::RequestComplete ( pStatus, ret );			
       
   150 		}
       
   151 	}
       
   152 
       
   153 EXPORT_C void RInternalSocket::Open(TUint aAddrFamily,  TUint aSockType, TUint aProtocol, TRequestStatus& aStatus )
       
   154 	{
       
   155 	__ASSERT_DEBUG(!iImplementation, InternalSocketPanic(ENotNullSocket));
       
   156 	LOG(Log::Printf(_L("RIS::Open(%d, %d, %d, %08x)"), aAddrFamily, aSockType, aProtocol, &aStatus));
       
   157 
       
   158 	aStatus = KRequestPending;
       
   159 		
       
   160 	TNodeId serverCookie;
       
   161 	TInt ret = CWorkerThread::CookieForProtocol(aAddrFamily, aSockType, aProtocol, serverCookie);
       
   162 	if(ret == KErrNone)
       
   163 		{
       
   164 		MCommsTransportSender* sender = &static_cast<MCommsTransportSender&>(TlsGlobals::Get().TransportSender());
       
   165 		TEIntSockOpMsgWrapper opMsg (aAddrFamily, aSockType, aProtocol);
       
   166 		TEIntSockMsgExt openMsg(ESoCreate, opMsg, iImplementation, aStatus, sender, serverCookie);
       
   167 		CInternalSockSubSession::SendMsg(openMsg, sender, serverCookie);
       
   168 		}
       
   169 	else
       
   170 		{
       
   171 		TRequestStatus* pStatus = &aStatus;
       
   172 		User::RequestComplete ( pStatus, ret );			
       
   173 		}		
       
   174 	}
       
   175 
       
   176 EXPORT_C void RInternalSocket::Send(const TDesC8& aDesc,TUint aFlags,TRequestStatus& aStatus)
       
   177 /**
       
   178 @see RSocket documentation
       
   179 */
       
   180 	{
       
   181 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   182 	LOG(Log::Printf(_L("RIS::Send(desc, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   183 
       
   184 	aStatus = KRequestPending;	
       
   185 	TEIntSockOpMsgWrapper opMsg( &aFlags, 0, &aDesc, EFalse);	
       
   186 	TEIntSockMsg msg(ESoSendNoLength, opMsg, iImplementation, aStatus);
       
   187 	iImplementation->SendMsg(msg);
       
   188 	}
       
   189 
       
   190 EXPORT_C void RInternalSocket::Send(RMBufChain& aData,TUint aFlags,TRequestStatus& aStatus)
       
   191 /**
       
   192 @see RSocket documentation
       
   193 */
       
   194 	{
       
   195 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   196 	LOG(Log::Printf(_L("RIS::Send(mbuf, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   197 	
       
   198 	aStatus = KRequestPending;
       
   199 	TEIntSockOpMsgWrapper opMsg(aFlags, 0, &aData, ETrue);
       
   200 	TEIntSockMsg msg(ESoSendNoLength, opMsg, iImplementation, aStatus);
       
   201 	iImplementation->SendMsg(msg);
       
   202 	}
       
   203 
       
   204 EXPORT_C void RInternalSocket::Send(const TDesC8& aDesc,TUint aFlags,TRequestStatus& aStatus,TSockXfrLength& aLen)
       
   205 /**
       
   206 @see RSocket documentation
       
   207 */
       
   208 	{
       
   209 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   210 	LOG(Log::Printf(_L("RIS::Send(desc+xferLen, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   211 	
       
   212 	aStatus = KRequestPending;	
       
   213 	aLen = aFlags;
       
   214 	TEIntSockOpMsgWrapper opMsg(&aLen, 0, &aDesc, EFalse);	
       
   215 	TEIntSockMsg msg(ESoSend, opMsg, iImplementation, aStatus);	
       
   216 	iImplementation->SendMsg(msg);
       
   217 	}
       
   218 
       
   219 EXPORT_C void RInternalSocket::Send(RMBufChain& aData,TUint aFlags,TRequestStatus& aStatus,TSockXfrLength& aLen)
       
   220 /**
       
   221 @see RSocket documentation
       
   222 */
       
   223 	{
       
   224 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   225 	LOG(Log::Printf(_L("RIS::Send(mbuf+xferLen, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   226 	
       
   227 	aStatus = KRequestPending;
       
   228 	aLen = aFlags;
       
   229 	TEIntSockOpMsgWrapper opMsg(&aLen, 0, &aData, ETrue);	
       
   230 	TEIntSockMsg msg(ESoSend, opMsg, iImplementation, aStatus);	
       
   231 	iImplementation->SendMsg(msg);
       
   232 	}
       
   233 
       
   234 EXPORT_C void RInternalSocket::SendTo(const TDesC8& aDesc,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus)
       
   235 	{
       
   236 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   237 	
       
   238 	aStatus = KRequestPending;
       
   239 	TEIntSockOpMsgWrapper opMsg(aFlags, &aAddr, &aDesc, EFalse);	
       
   240 	TEIntSockMsg msg(ESoSendToNoLength, opMsg, iImplementation, aStatus);
       
   241 	iImplementation->SendMsg(msg);	
       
   242 	}
       
   243 
       
   244 EXPORT_C void RInternalSocket::SendTo(RMBufChain& aData,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus)
       
   245 	{
       
   246 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   247 	
       
   248 	aStatus = KRequestPending;
       
   249 	TEIntSockOpMsgWrapper opMsg(aFlags, &aAddr, &aData, ETrue);	
       
   250 	TEIntSockMsg msg(ESoSendToNoLength, opMsg, iImplementation, aStatus);
       
   251 	iImplementation->SendMsg(msg);			
       
   252 	}
       
   253 
       
   254 EXPORT_C void RInternalSocket::SendTo(const TDesC8& aDesc,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus,TSockXfrLength& aLen)
       
   255 	{
       
   256 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   257 	
       
   258 	aLen = aFlags;
       
   259 	aStatus = KRequestPending;
       
   260 	TEIntSockOpMsgWrapper opMsg(&aLen, &aAddr, &aDesc, EFalse);	
       
   261 	TEIntSockMsg msg(ESoSendTo, opMsg, iImplementation, aStatus);		
       
   262 	iImplementation->SendMsg(msg);			
       
   263 	}
       
   264 
       
   265 EXPORT_C void RInternalSocket::SendTo(RMBufChain& aData, TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus,TSockXfrLength& aLen)
       
   266 	{
       
   267 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   268 	
       
   269 	aLen = aFlags;
       
   270 	aStatus = KRequestPending;
       
   271 	TEIntSockOpMsgWrapper opMsg(&aLen, &aAddr, &aData, ETrue);	
       
   272 	TEIntSockMsg msg(ESoSendTo, opMsg, iImplementation, aStatus);		
       
   273 	iImplementation->SendMsg(msg);					
       
   274 	}
       
   275 
       
   276 EXPORT_C void RInternalSocket::CancelSend()
       
   277 /**
       
   278 @see RSocket documentation
       
   279 */
       
   280 	{
       
   281 	LOG(Log::Printf(_L("RIS::CancelSend() impl=%08x"), iImplementation));
       
   282 	if(iImplementation)
       
   283 		{
       
   284 		TEIntSockOpMsgWrapper opMsg;
       
   285 		TEIntSockMsg msg(ESoCancelSend, opMsg, iImplementation);
       
   286 		iImplementation->SendReceiveMsg(msg);
       
   287 		}
       
   288 	}
       
   289 
       
   290 EXPORT_C void RInternalSocket::Recv(TDes8& aDesc,TUint aFlags,TRequestStatus& aStatus)
       
   291 /**
       
   292 @see RSocket documentation
       
   293 */
       
   294 	{
       
   295 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   296 	LOG(Log::Printf(_L("RIS::Recv(desc, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   297 	
       
   298 	aStatus = KRequestPending;
       
   299 	TEIntSockOpMsgWrapper opMsg(aFlags, 0, &aDesc, EFalse);
       
   300 	TEIntSockMsg msg(ESoRecvNoLength, opMsg, iImplementation, aStatus);
       
   301 	iImplementation->SendMsg(msg);
       
   302 	}
       
   303 
       
   304 EXPORT_C void RInternalSocket::Recv(RMBufChain& aData,TUint aFlags,TRequestStatus& aStatus)
       
   305 /**
       
   306 @see RSocket documentation
       
   307 */
       
   308 	{
       
   309 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   310 	LOG(Log::Printf(_L("RIS::Recv(mbuf, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   311 	
       
   312 	aStatus = KRequestPending;
       
   313 	TEIntSockOpMsgWrapper opMsg(aFlags, 0, &aData, ETrue);
       
   314 	TEIntSockMsg msg(ESoRecvNoLength, opMsg, iImplementation, aStatus);
       
   315 	iImplementation->SendMsg(msg);
       
   316 	}
       
   317 
       
   318 EXPORT_C void RInternalSocket::Recv(TDes8& aDesc, TUint aFlags, TRequestStatus& aStatus, TSockXfrLength& aLen)
       
   319 	{
       
   320 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   321 	
       
   322 	aLen = aFlags;
       
   323 	aStatus = KRequestPending;
       
   324 	TEIntSockOpMsgWrapper opMsg(&aLen, 0, &aDesc, EFalse);	
       
   325 	TEIntSockMsg msg(ESoRecv, opMsg, iImplementation, aStatus);	
       
   326 	iImplementation->SendMsg(msg);	
       
   327 	}
       
   328 
       
   329 EXPORT_C void RInternalSocket::Recv(RMBufChain& aData, TUint aFlags, TRequestStatus& aStatus, TSockXfrLength& aLen)
       
   330 	{
       
   331 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   332 	LOG(Log::Printf(_L("RIS::Recv(mbuf, flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   333 	
       
   334 	aLen = aFlags;		
       
   335 	aStatus = KRequestPending;
       
   336 	TEIntSockOpMsgWrapper opMsg(&aLen, 0, &aData, ETrue);	
       
   337 	TEIntSockMsg msg(ESoRecv, opMsg, iImplementation, aStatus);	
       
   338 	iImplementation->SendMsg(msg);		
       
   339 	}
       
   340 	
       
   341 /**
       
   342 @see RSocket documentation.
       
   343 
       
   344 Note: This API is not having a RMBufChain variant as a RIS::Recv with RMBufChain will give the exact behaviour 
       
   345 */
       
   346 EXPORT_C void RInternalSocket::RecvOneOrMore(TDes8& aDesc, TUint aFlags, TRequestStatus& aStatus, TSockXfrLength& aLen)
       
   347 	{
       
   348 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   349 	LOG(Log::Printf(_L("RIS::RecvOneOrMore(flags=%d, status=%08x) impl=%08x"), aFlags, &aStatus, iImplementation));
       
   350 	
       
   351 	aLen = aFlags;
       
   352 	aStatus = KRequestPending;
       
   353 	
       
   354 	TEIntSockOpMsgWrapper opMsg(&aLen, 0, &aDesc, EFalse);
       
   355 	TEIntSockMsg msg(ESoRecvOneOrMore, opMsg, iImplementation, aStatus );
       
   356 	iImplementation->SendMsg(msg);
       
   357 	}
       
   358 
       
   359 EXPORT_C void RInternalSocket::CancelRecv()
       
   360 /**
       
   361 @see RSocket documentation
       
   362 */
       
   363 	{
       
   364 	LOG(Log::Printf(_L("RIS::CancelRecv() impl=%08x"), iImplementation));
       
   365 	if(iImplementation)
       
   366 		{
       
   367 		TEIntSockOpMsgWrapper opMsg;
       
   368 		TEIntSockMsg msg (ESoCancelRecv, opMsg, iImplementation);
       
   369 		iImplementation->SendReceiveMsg(msg);
       
   370 		}
       
   371 	}
       
   372 
       
   373 EXPORT_C void RInternalSocket::RecvFrom(TDes8& aDesc,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus)
       
   374 	{
       
   375 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   376 	
       
   377 	aStatus = KRequestPending;
       
   378 	TEIntSockOpMsgWrapper opMsg(aFlags, &aAddr, &aDesc, EFalse);	
       
   379 	TEIntSockMsg msg(ESoRecvFromNoLength, opMsg, iImplementation, aStatus);
       
   380 	iImplementation->SendMsg(msg);		
       
   381 	}
       
   382 
       
   383 EXPORT_C void RInternalSocket::RecvFrom(RMBufChain& aData,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus)
       
   384 	{
       
   385 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   386 	
       
   387 	aStatus = KRequestPending;
       
   388 	TEIntSockOpMsgWrapper opMsg(aFlags, &aAddr, &aData, ETrue);	
       
   389 	TEIntSockMsg msg(ESoRecvFromNoLength, opMsg, iImplementation, aStatus);
       
   390 	iImplementation->SendMsg(msg);		
       
   391 	}
       
   392 
       
   393 EXPORT_C void RInternalSocket::RecvFrom(TDes8& aDesc,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus,TSockXfrLength& aLen)
       
   394 	{
       
   395 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   396 	
       
   397 	aStatus = KRequestPending;
       
   398 	aLen = aFlags;
       
   399 	TEIntSockOpMsgWrapper opMsg(&aLen, &aAddr, &aDesc, EFalse);	
       
   400 	TEIntSockMsg msg(ESoRecvFrom, opMsg, iImplementation, aStatus);	
       
   401 	iImplementation->SendMsg(msg);				
       
   402 	}
       
   403 
       
   404 EXPORT_C void RInternalSocket::RecvFrom(RMBufChain& aData,TSockAddr& aAddr,TUint aFlags,TRequestStatus& aStatus,TSockXfrLength& aLen)
       
   405 	{
       
   406 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   407 	
       
   408 	aLen = aFlags;
       
   409 	aStatus = KRequestPending;
       
   410 	TEIntSockOpMsgWrapper opMsg(&aLen, &aAddr, &aData, ETrue);	
       
   411 	TEIntSockMsg msg(ESoRecvFrom, opMsg, iImplementation, aStatus);	
       
   412 	iImplementation->SendMsg(msg);				
       
   413 	}
       
   414 
       
   415 
       
   416 EXPORT_C void RInternalSocket::Read(TDes8& aDesc,TRequestStatus& aStatus)
       
   417 /**
       
   418 @see RSocket documentation
       
   419 */
       
   420 	{
       
   421 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   422 	LOG(Log::Printf(_L("RIS::Read(desc, status=%08x) impl=%08x"), &aStatus, iImplementation));
       
   423 	
       
   424 	aStatus = KRequestPending;
       
   425 	TEIntSockOpMsgWrapper opMsg(0, 0, &aDesc, EFalse);	
       
   426 	TEIntSockMsg msg(ESoRead, opMsg, iImplementation, aStatus);	
       
   427 	iImplementation->SendMsg(msg);
       
   428 	}
       
   429 
       
   430 EXPORT_C void RInternalSocket::Read(RMBufChain& aData,TRequestStatus& aStatus)
       
   431 /**
       
   432 @see RSocket documentation
       
   433 @note Pass in an empty (ie. no mbufs attached) RMBuf chain here - the mbufs will be attached by the protocol
       
   434 */
       
   435 	{
       
   436 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   437 	LOG(Log::Printf(_L("RIS::Read(mbuf, status=%08x) impl=%08x"), &aStatus, iImplementation));
       
   438 	
       
   439 	aStatus = KRequestPending;
       
   440 	TEIntSockOpMsgWrapper opMsg(0, 0, &aData, ETrue);	
       
   441 	TEIntSockMsg msg(ESoRead, opMsg, iImplementation, aStatus);	
       
   442 	iImplementation->SendMsg(msg);
       
   443 	}
       
   444 
       
   445 EXPORT_C void RInternalSocket::CancelRead()
       
   446 /**
       
   447 @see RSocket documentation
       
   448 */
       
   449 	{
       
   450 	LOG(Log::Printf(_L("RIS::CancelRead() impl=%08x"), iImplementation));
       
   451 	if(iImplementation)
       
   452 		{
       
   453 		TEIntSockOpMsgWrapper opMsg;
       
   454 		TEIntSockMsg msg (ESoCancelRecv, opMsg, iImplementation);
       
   455 		iImplementation->SendReceiveMsg(msg);
       
   456 		}
       
   457 	}
       
   458 
       
   459 EXPORT_C void RInternalSocket::Write(const TDesC8& aDesc, TRequestStatus& aStatus)
       
   460 /**
       
   461 @see RSocket documentation
       
   462 */
       
   463 	{
       
   464 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   465 	LOG(Log::Printf(_L("RIS::Write(desc, status=%08x) impl=%08x"), &aStatus, iImplementation));
       
   466 	
       
   467 	aStatus = KRequestPending;
       
   468 	TEIntSockOpMsgWrapper opMsg(0, 0, &aDesc, EFalse);		
       
   469 	TEIntSockMsg msg (ESoWrite, opMsg, iImplementation, aStatus);	
       
   470 	iImplementation->SendMsg(msg);
       
   471 	}
       
   472 
       
   473 EXPORT_C void RInternalSocket::Write(RMBufChain& aData, TRequestStatus& aStatus)
       
   474 /**
       
   475 @see RSocket documentation
       
   476 */
       
   477 	{
       
   478 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   479 	LOG(Log::Printf(_L("RIS::Write(mbuf, status=%08x) impl=%08x"), &aStatus, iImplementation));
       
   480 	
       
   481 	aStatus = KRequestPending;
       
   482 	TEIntSockOpMsgWrapper opMsg(0, 0, &aData, ETrue);
       
   483 	TEIntSockMsg msg (ESoWrite, opMsg, iImplementation, aStatus);	
       
   484 	iImplementation->SendMsg(msg);
       
   485 	}
       
   486 
       
   487 EXPORT_C void RInternalSocket::CancelWrite()
       
   488 /**
       
   489 @see RSocket documentation
       
   490 */
       
   491 	{
       
   492 	LOG(Log::Printf(_L("RIS::CancelWrite() impl=%08x"), iImplementation));
       
   493 	if(iImplementation)
       
   494 		{
       
   495 		TEIntSockOpMsgWrapper opMsg;
       
   496 		TEIntSockMsg msg (ESoCancelSend, opMsg, iImplementation);
       
   497 		iImplementation->SendReceiveMsg(msg);
       
   498 		}
       
   499 	}
       
   500 
       
   501 EXPORT_C void RInternalSocket::Connect(TSockAddr& aAddr,TRequestStatus& aStatus)
       
   502 /**
       
   503 @see RSocket documentation
       
   504 */
       
   505 	{
       
   506 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   507 	LOG(Log::Printf(_L("RIS::Connect(status=%08x) impl=%08x"), &aStatus, iImplementation));
       
   508 	
       
   509 	aStatus = KRequestPending;
       
   510 	TEIntSockOpMsgWrapper opMsg(&aAddr, NULL, NULL);
       
   511 	TEIntSockMsg msg (ESoConnect, opMsg, iImplementation, aStatus);
       
   512 	iImplementation->SendMsg(msg);
       
   513 	}
       
   514 
       
   515 EXPORT_C void RInternalSocket::Connect(TSockAddr& aAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn,TRequestStatus& aStatus)
       
   516 /**
       
   517 @see RSocket documentation
       
   518 */
       
   519 	{
       
   520 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   521 	LOG(Log::Printf(_L("RIS::Connect(withdata, status=%08x) impl=%08x"), &aStatus, iImplementation));
       
   522 	
       
   523 	aStatus = KRequestPending;
       
   524 	TEIntSockOpMsgWrapper opMsg(&aAddr, &aConnectDataOut, &aConnectDataIn);
       
   525 	TEIntSockMsg msg (ESoConnect, opMsg, iImplementation, aStatus);
       
   526 	iImplementation->SendMsg(msg);
       
   527 	}
       
   528 
       
   529 EXPORT_C void RInternalSocket::CancelConnect()
       
   530 /**
       
   531 @see RSocket documentation
       
   532 */
       
   533 	{
       
   534 	LOG(Log::Printf(_L("RIS::CancelConnect() impl=%08x"), iImplementation));
       
   535 	if(iImplementation)
       
   536 		{
       
   537 		TEIntSockOpMsgWrapper opMsg;		
       
   538 		TEIntSockMsg msg (ESoCancelConnect, opMsg, iImplementation);
       
   539 		iImplementation->SendReceiveMsg(msg);
       
   540 		}
       
   541 	}
       
   542 
       
   543 EXPORT_C TInt RInternalSocket::Bind(TSockAddr& aAddr)
       
   544 /**
       
   545 @see RSocket documentation
       
   546 */
       
   547 	{
       
   548 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   549 	LOG(Log::Printf(_L("RIS::Bind() impl=%08x"), iImplementation));
       
   550 	TEIntSockOpMsgWrapper opMsg(&aAddr);	
       
   551 	TEIntSockMsg msg (ESoBind, opMsg, iImplementation);
       
   552 	return iImplementation->SendReceiveMsg(msg);
       
   553 	}
       
   554 
       
   555 EXPORT_C TInt RInternalSocket::SetLocalPort(TInt aPort)
       
   556 /**
       
   557 @see RSocket documentation
       
   558 */
       
   559 	{
       
   560 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   561 	LOG(Log::Printf(_L("RIS::SetLocalPort(%d) impl=%08x"), aPort, iImplementation));
       
   562 	TSockAddr addr;
       
   563 	addr.SetPort ( aPort );
       
   564 	return Bind ( addr );
       
   565 	}
       
   566 
       
   567 EXPORT_C void RInternalSocket::Accept(RInternalSocket& aBlankSocket,TRequestStatus& aStatus)
       
   568 /**
       
   569 @see RSocket documentation
       
   570 */
       
   571 	{
       
   572 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   573 	LOG(Log::Printf(_L("RIS::Accept(blankImpl=%08x, status=%08x) impl=%08x"), aBlankSocket.iImplementation, &aStatus, iImplementation));
       
   574 
       
   575 	aStatus = KRequestPending;
       
   576 	TInt ret = AdoptBlankSocketToCurrentThread (aBlankSocket );
       
   577 	if(ret == KErrNone)
       
   578 		{
       
   579 		// Finally can process the accept
       
   580 		TEIntSockOpMsgWrapper opMsg(NULL, &aBlankSocket, NULL);
       
   581 		TEIntSockMsg msg (ESoAccept, opMsg, iImplementation, aStatus);
       
   582 		iImplementation->SendMsg(msg);
       
   583 		}
       
   584 	else
       
   585 		{
       
   586 		// Complete the accept with the error that arose trying to do it
       
   587 		LOG(Log::Printf(_L("RIS::Accept - error %d when substituting blanks"), ret));
       
   588 		TRequestStatus* status = &aStatus;
       
   589 		User::RequestComplete(status, ret);
       
   590 		}
       
   591 	}
       
   592 
       
   593 EXPORT_C void RInternalSocket::Accept(RInternalSocket& aBlankSocket,TDes8& aConnectData,TRequestStatus& aStatus)
       
   594 	{
       
   595 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   596 	LOG(Log::Printf(_L("RIS::Accept(blankImpl=%08x, status=%08x) impl=%08x"), aBlankSocket.iImplementation, &aStatus, iImplementation));
       
   597 
       
   598 	aStatus = KRequestPending;
       
   599 	TInt ret = AdoptBlankSocketToCurrentThread (aBlankSocket );
       
   600 	if(ret == KErrNone)
       
   601 		{
       
   602 		// Finally can process the accept
       
   603 		TEIntSockOpMsgWrapper opMsg(NULL, &aBlankSocket, &aConnectData);		
       
   604 		TEIntSockMsg msg (ESoAccept, opMsg, iImplementation, aStatus);
       
   605 		iImplementation->SendMsg(msg);
       
   606 		}
       
   607 	else
       
   608 		{
       
   609 		// Complete the accept with the error that arose trying to do it
       
   610 		LOG(Log::Printf(_L("RIS::Accept - error %d when substituting blanks"), ret));
       
   611 		TRequestStatus* status = &aStatus;
       
   612 		User::RequestComplete(status, ret);
       
   613 		}		
       
   614 	}
       
   615 
       
   616 EXPORT_C void RInternalSocket::CancelAccept()
       
   617 /**
       
   618 @see RSocket documentation
       
   619 */
       
   620 	{
       
   621 	LOG(Log::Printf(_L("RIS::CancelAccept() impl=%08x"), iImplementation));
       
   622 	if(iImplementation)
       
   623 		{
       
   624 		TEIntSockOpMsgWrapper opMsg;
       
   625 		TEIntSockMsg msg (ESoCancelAccept, opMsg, iImplementation);
       
   626 		iImplementation->SendReceiveMsg(msg);
       
   627 		}
       
   628 	}
       
   629 
       
   630 EXPORT_C TInt RInternalSocket::Listen(TUint aQSize)
       
   631 /**
       
   632 @see RSocket documentation
       
   633 */
       
   634 	{
       
   635 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   636 	LOG(Log::Printf(_L("RIS::Listen(%d) impl=%08x"), aQSize, iImplementation));
       
   637 	
       
   638 	TEIntSockOpMsgWrapper opMsg(aQSize, NULL);
       
   639 	TEIntSockMsg msg (ESoListen, opMsg, iImplementation);
       
   640 	return iImplementation->SendReceiveMsg(msg);
       
   641 	}
       
   642 
       
   643 EXPORT_C TInt RInternalSocket::Listen(TUint aQSize,const TDesC8& aConnectData)
       
   644 /**
       
   645 @see RSocket documentation
       
   646 */
       
   647 	{
       
   648 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   649 	LOG(Log::Printf(_L("RIS::Listen(withData, %d) impl=%08x"), aQSize, iImplementation));
       
   650 	
       
   651 	TEIntSockOpMsgWrapper opMsg(aQSize, &aConnectData);
       
   652 	TEIntSockMsg msg (ESoListen, opMsg, iImplementation);
       
   653 	return iImplementation->SendReceiveMsg(msg);
       
   654 	}
       
   655 
       
   656 EXPORT_C TInt RInternalSocket::SetOpt(TUint aOptionName,TUint aOptionLevel,const TDesC8& aOption)
       
   657 /**
       
   658 @see RSocket documentation
       
   659 */
       
   660 	{
       
   661 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   662 	LOG(Log::Printf(_L("RIS::SetOpt(%d, %d) impl=%08x"), aOptionName, aOptionLevel, iImplementation));
       
   663 	
       
   664 	TEIntSockOpMsgWrapper opMsg(aOptionName,&aOption,aOptionLevel);
       
   665 	TEIntSockMsg msg (ESoSetOpt, opMsg, iImplementation);  	
       
   666 	return iImplementation->SendReceiveMsg(msg);
       
   667 	}
       
   668 
       
   669 EXPORT_C TInt RInternalSocket::SetOpt(TUint aOptionName,TUint aOptionLevel,TInt aOption)
       
   670 /**
       
   671 @see RSocket documentation
       
   672 */
       
   673 	{
       
   674 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   675 	LOG(Log::Printf(_L("RIS::SetOpt(%d, %d, %d) impl=%08x"), aOptionName, aOptionLevel, aOption, iImplementation));
       
   676 	
       
   677 	TPtr8 optionDes( (TUint8*)&aOption, sizeof(TInt), sizeof(TInt) );
       
   678 	return SetOpt ( aOptionName, aOptionLevel, optionDes );
       
   679 	}
       
   680 
       
   681 EXPORT_C TInt RInternalSocket::GetOpt(TUint aOptionName,TUint aOptionLevel,TDes8& aOption)
       
   682 /**
       
   683 @see RSocket documentation
       
   684 */
       
   685 	{
       
   686 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   687 	LOG(Log::Printf(_L("RIS::GetOpt(%d, %d) impl=%08x"), aOptionName, aOptionLevel, iImplementation));
       
   688 
       
   689 	TEIntSockOpMsgWrapper opMsg(aOptionName,&aOption,aOptionLevel);
       
   690 	TEIntSockMsg msg (ESoGetOpt, opMsg, iImplementation);  	
       
   691 	return iImplementation->SendReceiveMsg(msg);
       
   692 	}
       
   693 
       
   694 EXPORT_C TInt RInternalSocket::GetOpt(TUint aOptionName,TUint aOptionLevel,TInt& aOption)
       
   695 /**
       
   696 @see RSocket documentation
       
   697 */
       
   698 	{
       
   699 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   700 	LOG(Log::Printf(_L("RIS::GetOpt(%d, %d) impl=%08x"), aOptionName, aOptionLevel, iImplementation));
       
   701 	
       
   702 	TPtr8 optionDes( (TUint8*)&aOption, sizeof(TInt), sizeof(TInt) );
       
   703 	return GetOpt ( aOptionName, aOptionLevel, optionDes );
       
   704 	}
       
   705 
       
   706 EXPORT_C void RInternalSocket::Ioctl(TUint aCommand,TRequestStatus& aStatus,TDes8* aDesc,TUint aLevel)
       
   707 /**
       
   708 @see RSocket documentation
       
   709 */
       
   710 	{
       
   711 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   712 	LOG(Log::Printf(_L("RIS::Ioctl(cmd=%d, level=%d, aStatus=%08x) impl=%08x"), aCommand, aLevel, &aStatus, iImplementation));
       
   713 
       
   714 	aStatus = KRequestPending;
       
   715 	TEIntSockOpMsgWrapper opMsg(aCommand,aDesc,aLevel);	
       
   716 	TEIntSockMsg msg (ESoIoctl, opMsg, iImplementation, aStatus);  	
       
   717 	iImplementation->SendMsg(msg);
       
   718 	}
       
   719 
       
   720 EXPORT_C void RInternalSocket::CancelIoctl()
       
   721 /**
       
   722 @see RSocket documentation
       
   723 */
       
   724 	{
       
   725 	LOG(Log::Printf(_L("RIS::CancelIoctl() impl=%08x"), iImplementation));
       
   726 	if(iImplementation)
       
   727 		{
       
   728 		TEIntSockOpMsgWrapper opMsg;
       
   729 		TEIntSockMsg msg (ESoCancelIoctl, opMsg, iImplementation);
       
   730 		iImplementation->SendReceiveMsg(msg);
       
   731 		}
       
   732 	}
       
   733 
       
   734 EXPORT_C TInt RInternalSocket::GetDisconnectData(TDes8& aDesc)
       
   735 /**
       
   736 @see RSocket documentation
       
   737 */
       
   738 	{
       
   739 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   740 	LOG(Log::Printf(_L("RIS::GetDisconnectData() impl=%08x"), iImplementation));
       
   741 	TEIntSockOpMsgWrapper opMsg(&aDesc);
       
   742 	TEIntSockMsg msg (ESoGetDiscData, opMsg, iImplementation);	 
       
   743 	return iImplementation->SendReceiveMsg(msg);
       
   744 	}
       
   745 
       
   746 EXPORT_C void RInternalSocket::LocalName(TSockAddr& aAddr)
       
   747 /**
       
   748 @see RSocket documentation
       
   749 */
       
   750 	{
       
   751 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   752 	LOG(Log::Printf(_L("RIS::LocalName() impl=%08x"), iImplementation));
       
   753 
       
   754 	TEIntSockOpMsgWrapper opMsg(&aAddr);
       
   755 	TEIntSockMsg msg (ESoGetLocalName, opMsg, iImplementation);	 
       
   756 	iImplementation->SendReceiveMsg(msg);
       
   757 	}
       
   758 
       
   759 EXPORT_C TUint RInternalSocket::LocalPort()
       
   760 /**
       
   761 @see RSocket documentation
       
   762 */
       
   763 	{
       
   764 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   765 	LOG(Log::Printf(_L("RIS::LocalPort() impl=%08x"), iImplementation));
       
   766 	
       
   767 	TSockAddr addr;
       
   768 	LocalName ( addr );
       
   769 	return addr.Port();
       
   770 	}
       
   771 
       
   772 EXPORT_C void RInternalSocket::RemoteName(TSockAddr& aAddr)
       
   773 /**
       
   774 @see RSocket documentation
       
   775 */
       
   776 	{
       
   777 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   778 	LOG(Log::Printf(_L("RIS::RemoteName() impl=%08x"), iImplementation));
       
   779 	
       
   780 	TEIntSockOpMsgWrapper opMsg(&aAddr);
       
   781 	TEIntSockMsg msg (ESoGetRemoteName, opMsg, iImplementation);	 
       
   782 	iImplementation->SendReceiveMsg(msg);
       
   783 	}
       
   784 
       
   785 EXPORT_C void RInternalSocket::Close()
       
   786 /**
       
   787 @see RSocket documentation
       
   788 */
       
   789 	{
       
   790 	LOG(Log::Printf(_L("RIS::Close() impl=%08x"), iImplementation));
       
   791 	if(iImplementation)
       
   792 		{
       
   793 		CInternalSocketImpl* impl = iImplementation;
       
   794 		iImplementation = NULL; // this will leave the implementation "floating", but it's a CObject
       
   795 								// and will delete itself once the protocol calls CanClose()
       
   796 		TEIntSockOpMsgWrapper opMsg;
       
   797 		TEIntSockMsg msg (ESoClose, opMsg, impl);	 
       
   798 		impl->SendReceiveMsg(msg);
       
   799 		}
       
   800 	}
       
   801 
       
   802 EXPORT_C void RInternalSocket::Shutdown(RSocket::TShutdown aHow,TRequestStatus& aStatus)
       
   803 /**
       
   804 @see RSocket documentation
       
   805 */
       
   806 	{
       
   807 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   808 	LOG(Log::Printf(_L("RIS::Shutdown(how=%d, status=%08x) impl=%08x"), aHow, &aStatus, iImplementation));
       
   809 	
       
   810 	aStatus = KRequestPending;
       
   811 	TEIntSockOpMsgWrapper opMsg(aHow);
       
   812 	TEIntSockMsg msg (ESoShutdown, opMsg, iImplementation, aStatus);	 
       
   813 	iImplementation->SendMsg(msg);
       
   814 	}
       
   815 
       
   816 EXPORT_C void RInternalSocket::Shutdown(RSocket::TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn,TRequestStatus& aStatus)
       
   817 /**
       
   818 @see RSocket documentation
       
   819 */
       
   820 	{
       
   821 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   822 	LOG(Log::Printf(_L("RIS::Shutdown(withData, how=%d, status=%08x), impl=%08x"), aHow, &aStatus, iImplementation));
       
   823 	
       
   824 	aStatus = KRequestPending;
       
   825 	TEIntSockOpMsgWrapper opMsg(aHow, &aDisconnectDataOut, &aDisconnectDataIn);	
       
   826 	TEIntSockMsg msg (ESoShutdown, opMsg, iImplementation, aStatus);	 
       
   827 	iImplementation->SendMsg(msg);
       
   828 	}
       
   829 
       
   830 EXPORT_C void RInternalSocket::CancelAll()
       
   831 /**
       
   832 @see RSocket documentation
       
   833 */
       
   834 	{
       
   835 	LOG(Log::Printf(_L("RIS::CancelAll() impl=%08x"), iImplementation));
       
   836 	if(iImplementation)
       
   837 		{
       
   838 		TEIntSockOpMsgWrapper opMsg;
       
   839 		TEIntSockMsg msg (ESoCancelAll, opMsg, iImplementation);	 
       
   840 		iImplementation->SendReceiveMsg(msg);
       
   841 		}
       
   842 	}
       
   843 
       
   844 EXPORT_C TInt RInternalSocket::Info(TProtocolDesc& aProtocol)
       
   845 /**
       
   846 @see RSocket documentation
       
   847 */
       
   848 	{
       
   849 	__ASSERT_ALWAYS(iImplementation, InternalSocketPanic(ENullSocket));
       
   850 	LOG(Log::Printf(_L("RIS::Info() impl=%08x"), iImplementation));
       
   851 
       
   852 	TPckg<TProtocolDesc> protocolDesc(aProtocol);
       
   853 	TEIntSockOpMsgWrapper opMsg(&protocolDesc);
       
   854 	TEIntSockMsg msg (ESoSocketInfo, opMsg, iImplementation);	 
       
   855 	return iImplementation->SendReceiveMsg(msg);
       
   856 	}
       
   857 
       
   858 // don't support socket ::Name() with internal sockets	- IMPORT_C TInt Name(TName& aName);
       
   859 
       
   860 EXPORT_C TInt RInternalSocket::Transfer(RInternalSocket& aSource)
       
   861 /**
       
   862 @see RSocket documentation
       
   863 @note Rather than a two-stage ::Name(), ::Transfer(), this can be done in a single operation
       
   864 */
       
   865 	{
       
   866 	__ASSERT_ALWAYS(!iImplementation, InternalSocketPanic(ENullSocket)); // check that we're not about to overwrite another socket
       
   867 	LOG(Log::Printf(_L("RIS::Transfer(srcImp=%08x) impl=%08x"), aSource.iImplementation, iImplementation));
       
   868 
       
   869 	// Should we ASSERT no cross thread problem here?
       
   870 	iImplementation = aSource.Implementation();
       
   871 	aSource.SetImplementation(NULL);
       
   872 
       
   873     // Get a new transport sender incase the transfer was cross thread
       
   874 	iImplementation->SetSender(&static_cast<MCommsTransportSender&>(TlsGlobals::Get().TransportSender()));
       
   875 	return(KErrNone);
       
   876 	}
       
   877 
       
   878 // ---
       
   879 TInt RInternalSocket::AdoptBlankSocketToCurrentThread ( RInternalSocket& aBlankSocket )
       
   880 	{
       
   881 	// Now that we know just which thread they are using the blank socket we can destroy the original
       
   882 	// and create it where it should have been all along. Note that this code imposes the minor restriction
       
   883 	// that the blank RInternalSocket must not have been aliased, because we're destroying the original
       
   884 	// implementation and setting aBlankSocket.iImpl to the new one. This limitation compared to RSocket
       
   885 	// (where the IPC handle mechanism hides the pointer) seems acceptable - it's small and the audience
       
   886 	// must be knowledgeable and careful anyway. Unfortunately we can't ASSERT that they haven't aliased - 
       
   887 	// the best we could do is log whenever they do, but the first time we see it could be after they've
       
   888 	// aliased the blank, ie it wouldn't necessarily catch this case. The alternative to avoid changing the
       
   889 	// implementation pointer would be providing a forwarding mechanism: non-trivial
       
   890 
       
   891 	TInt ret = KErrNone;
       
   892 	if(iImplementation->ServerWorkerId() != aBlankSocket.iImplementation->ServerWorkerId())
       
   893 		{
       
   894 		// Blank was created in wrong thread. Perhaps v1.1 of the Precognition module will work better!
       
   895 		LOG(Log::Printf(_L("RIS::Accept - creating new blank in listener's thread")));
       
   896 		TNodeId newBlankCookie;
       
   897 		ret = CWorkerThread::CookieForWorkerId(iImplementation->ServerWorkerId(), newBlankCookie);
       
   898 		if(ret == KErrNone)
       
   899 			{
       
   900 			CInternalSocketImpl* oldBlankImplementation = aBlankSocket.iImplementation;
       
   901 			aBlankSocket.iImplementation = NULL;
       
   902 			TEIntSockOpMsgWrapper opMsg;
       
   903 			TEIntSockMsgExt msg(ESoCreateNull, opMsg, aBlankSocket.iImplementation, iImplementation->Sender(), newBlankCookie);
       
   904 			ret = CInternalSockSubSession::SendReceiveMsg(msg, iImplementation->Sender(), newBlankCookie);
       
   905 			if(ret == KErrNone)
       
   906 				{
       
   907 				// Tell the original blank socket owner to delete the implementation
       
   908 				LOG(Log::Printf(_L("RIS::Accept - closing original blank")));
       
   909 				RInternalSocket oldBlankSocket;
       
   910 				oldBlankSocket.iImplementation = oldBlankImplementation;
       
   911 				oldBlankSocket.Close();
       
   912 				}
       
   913 			else
       
   914 				{
       
   915 				aBlankSocket.iImplementation = oldBlankImplementation;	// rollback
       
   916 				}
       
   917 			}
       
   918 		}
       
   919 	return ret;		
       
   920 	}
       
   921 
       
   922