plugins/networking/winsockprt/src/wsp_provider.cpp
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // wsp_provider.cpp
       
     2 // 
       
     3 // Copyright (c) 2002 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 
       
    14 #include "wsp_provider.h"
       
    15 #include "wsp_factory.h"
       
    16 #include "wsp_socket.h"
       
    17 #include "wsp_panic.h"
       
    18 #include "wsp_log.h"
       
    19 
       
    20 
       
    21 //
       
    22 // Constants.
       
    23 //
       
    24 
       
    25 const TInt KReceiveBufferSize = 4096;
       
    26 
       
    27 
       
    28 //
       
    29 // CWinSockProviderBase.
       
    30 //
       
    31 
       
    32 CWinSockProviderBase::CWinSockProviderBase(RWin32Factory& aWin32Factory)
       
    33 	: iWin32Factory(aWin32Factory), iWinSockWriteBuffer(NULL, 0)
       
    34 	{
       
    35 	}
       
    36 
       
    37 CWinSockProviderBase::~CWinSockProviderBase()
       
    38 	{
       
    39 	delete iSendSocketWrapper;
       
    40 	delete iReceiveSocketWrapper;
       
    41 	delete iReceiveBuffer;
       
    42 	delete iSendBuffer;
       
    43 	iWin32Socket.Close();
       
    44 	}
       
    45 
       
    46 void CWinSockProviderBase::ConstructL()
       
    47 	{
       
    48 	iSendSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
       
    49 	iReceiveSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
       
    50 	iReceiveBuffer = HBufC8::NewL(KReceiveBufferSize);
       
    51 	iWinSockWriteBuffer.Set(iReceiveBuffer->Des());
       
    52 	}
       
    53 
       
    54 TInt CWinSockProviderBase::FillSendBuffer(const TDesC8& aDataToSend)
       
    55 	{
       
    56 	if (iSendBuffer)
       
    57 		{
       
    58 		if (iSendBuffer->Des().MaxLength() < aDataToSend.Length())
       
    59 			{
       
    60 			iSendBuffer = iSendBuffer->ReAlloc(aDataToSend.Length());
       
    61 			if (iSendBuffer == NULL)
       
    62 				{
       
    63 				return KErrNoMemory;
       
    64 				}
       
    65 			}
       
    66 		*iSendBuffer = aDataToSend;
       
    67 		}
       
    68 	else
       
    69 		{
       
    70 		iSendBuffer = aDataToSend.Alloc();
       
    71 		if (iSendBuffer == NULL)
       
    72 			{
       
    73 			return KErrNoMemory;
       
    74 			}
       
    75 		}
       
    76 	return KErrNone;
       
    77 	}
       
    78 
       
    79 TInt CWinSockProviderBase::SetRemName(TSockAddr& anAddr)
       
    80 	{
       
    81 	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::SetRemName")));
       
    82 	iRemoteAddr = anAddr;
       
    83 	return KErrNone;
       
    84 	}
       
    85 
       
    86 void CWinSockProviderBase::LocalName(TSockAddr& anAddr)const
       
    87 	{
       
    88 	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::LocalName")));
       
    89 	iWin32Socket.GetSocketName(static_cast<TInetAddr&>(anAddr)); // Throw away error code.
       
    90 	}
       
    91 
       
    92 TInt CWinSockProviderBase::SetLocalName(TSockAddr& anAddr)
       
    93 	{
       
    94 	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::SetLocalName")));
       
    95 	return iWin32Socket.Bind(anAddr);
       
    96 	}
       
    97 
       
    98 void CWinSockProviderBase::AutoBind( void )
       
    99 	{
       
   100 	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::AutoBind")));
       
   101 	}
       
   102 
       
   103 TInt CWinSockProviderBase::GetOption(TUint /*aLevel*/, TUint /*aName*/, TDes8& /*anOption*/)const
       
   104 	{
       
   105 	return KErrNotSupported;
       
   106 	}
       
   107 
       
   108 TInt CWinSockProviderBase::SetOption(TUint /*aLevel*/, TUint /*aName*/, const TDesC8& /*anOption*/)
       
   109 	{
       
   110 	return KErrNotSupported;
       
   111 	}
       
   112 
       
   113 void CWinSockProviderBase::Ioctl(TUint /*aLevel*/, TUint /*aName*/, TDes8* /*anOption*/)
       
   114 	{
       
   115 	iSocket->Error(KErrNotSupported, MSocketNotify::EErrorIoctl);
       
   116 	}
       
   117 
       
   118 void CWinSockProviderBase::CancelIoctl(TUint /*aLevel*/, TUint /*aName*/)
       
   119 	{
       
   120 	}
       
   121 
       
   122 TInt CWinSockProviderBase::PassiveOpen(TUint /*aQue*/, const TDesC8& /*aConnectionData*/)
       
   123 	{
       
   124 	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedActivePassiveOpenWithConnectionData));
       
   125 	return 0;
       
   126 	}
       
   127 
       
   128 void CWinSockProviderBase::Shutdown(TCloseType /*option*/, const TDesC8& /*aDisconnectData*/)
       
   129 	{
       
   130 	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedActiveShutdownWithConnectionData));
       
   131 	}
       
   132 
       
   133 void CWinSockProviderBase::ActiveOpen(const TDesC8& /*aConnectionData*/)
       
   134 	{
       
   135 	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedActiveOpenCallWithConnectionData));
       
   136 	}
       
   137 
       
   138 void CWinSockProviderBase::Shutdown(TCloseType aType)
       
   139 	{
       
   140 	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::Shutdown")));
       
   141 	if (aType != EImmediate)
       
   142 		{
       
   143 		iSocket->CanClose();
       
   144 		}
       
   145 	}
       
   146 
       
   147 
       
   148 //
       
   149 // CWinSockTcpProvider.
       
   150 //
       
   151 
       
   152 CWinSockTcpProvider* CWinSockTcpProvider::NewL(RWin32Factory& aWin32Factory)
       
   153 	{
       
   154 	CWinSockTcpProvider* self = new(ELeave) CWinSockTcpProvider(aWin32Factory);
       
   155 	CleanupStack::PushL(self);
       
   156 	self->ConstructL(RWin32Socket::ETcp);
       
   157 	CleanupStack::Pop(self);
       
   158 	return self;
       
   159 	}
       
   160 
       
   161 CWinSockTcpProvider* CWinSockTcpProvider::NewBlankLC(RWin32Factory& aWin32Factory)
       
   162 	{
       
   163 	CWinSockTcpProvider* self = new(ELeave) CWinSockTcpProvider(aWin32Factory);
       
   164 	CleanupStack::PushL(self);
       
   165 	self->ConstructL(RWin32Socket::EBlank);
       
   166 	return self;
       
   167 	}
       
   168 
       
   169 CWinSockTcpProvider::CWinSockTcpProvider(RWin32Factory& aWin32Factory)
       
   170 	: CWinSockProviderBase(aWin32Factory)
       
   171 	{
       
   172 	}
       
   173 
       
   174 void CWinSockTcpProvider::ConstructL(RWin32Socket::TType aType)
       
   175 	{
       
   176 	User::LeaveIfError(iWin32Socket.Open(iWin32Factory, aType));
       
   177 	iConnectSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
       
   178 	iAcceptSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
       
   179 	CWinSockProviderBase::ConstructL();
       
   180 	}
       
   181 
       
   182 CWinSockTcpProvider::~CWinSockTcpProvider()
       
   183 	{
       
   184 	delete iConnectSocketWrapper;
       
   185 	delete iAcceptSocketWrapper;
       
   186 	delete iAcceptSap;
       
   187 	}
       
   188 
       
   189 void CWinSockTcpProvider::RemName(TSockAddr& anAddr) const
       
   190 	{
       
   191 	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::RemName")));
       
   192 	iWin32Socket.GetPeerName(static_cast<TInetAddr&>(anAddr)); // Throw away error code.
       
   193 	}
       
   194 
       
   195 TUint CWinSockTcpProvider::Write(const TDesC8& aDesc, TUint /*options*/, TSockAddr* /*anAddr*/)
       
   196 	{
       
   197 	WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::Write: writing %d bytes"), aDesc.Length()));
       
   198 	WSP_RAW_LOG(WspLog::WriteRawOutbound(aDesc));
       
   199 	if (iSendSocketWrapper->IsActive())
       
   200 		{
       
   201 		return 0;
       
   202 		}
       
   203 
       
   204 	TInt err = FillSendBuffer(aDesc);
       
   205 	if (err)
       
   206 		{
       
   207 		iSocket->Error(err, MSocketNotify::EErrorSend);
       
   208 		return 0;
       
   209 		}
       
   210 	iSendSocketWrapper->Send(*iSendBuffer);
       
   211 	return iSendBuffer->Length();
       
   212 	}
       
   213 
       
   214 void CWinSockTcpProvider::GetData(TDes8& aDesc, TUint /*aOptions*/, TSockAddr* /*anAddr*/)
       
   215 	{
       
   216 	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::GetData")));
       
   217 	TInt esockBufferSize = aDesc.Length();
       
   218 	if (esockBufferSize >= iEsockReadBuffer.Length())
       
   219 		{
       
   220 		WSP_LOG(WspLog::Printf(_L("\tCopying all %d bytes up to ESock"), iEsockReadBuffer.Length()));
       
   221 		aDesc.Copy(iEsockReadBuffer);
       
   222 		StartReceive();
       
   223 		}
       
   224 	else
       
   225 		{
       
   226 		WSP_LOG(WspLog::Printf(_L("\tESock buffer size: %d, available data: %d"), esockBufferSize, iEsockReadBuffer.Length()));
       
   227 		aDesc.Copy(iEsockReadBuffer.Left(esockBufferSize));
       
   228 		iEsockReadBuffer.Set(iEsockReadBuffer.Right(iEsockReadBuffer.Length() - esockBufferSize));
       
   229 		}
       
   230 
       
   231 	WSP_RAW_LOG(WspLog::WriteRawInbound(aDesc));
       
   232 	}
       
   233 
       
   234 void CWinSockTcpProvider::Start()
       
   235 	{
       
   236 	if (iListeningSap)
       
   237 		{
       
   238 		iListeningSap->HandleListeningSapStarted();
       
   239 		iListeningSap = NULL;
       
   240 		}
       
   241 	}
       
   242 
       
   243 void CWinSockTcpProvider::ActiveOpen()
       
   244 	{
       
   245 	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::ActiveOpen")));
       
   246 	TInt err = iConnectSocketWrapper->Connect(iRemoteAddr);
       
   247 	if (err)
       
   248 		{
       
   249 		iSocket->Error(err, MSocketNotify::EErrorConnect);
       
   250 		}
       
   251 	}
       
   252 
       
   253 TInt CWinSockTcpProvider::PassiveOpen(TUint aQue)
       
   254 	{
       
   255 	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::PassiveOpen")));
       
   256 	TRAPD(err, DoPassiveOpenL(aQue));
       
   257 	return err;
       
   258 	}
       
   259 
       
   260 TInt CWinSockTcpProvider::GetOption(TUint aLevel, TUint aName, TDes8& anOption) const
       
   261 	{
       
   262 	if (aLevel == KSolInetTcp)
       
   263 		{
       
   264 		switch (aName)
       
   265 			{
       
   266 			case KSoTcpNoDelay:
       
   267 				{
       
   268 				BOOL bOptVal = FALSE;
       
   269 				TInt length = sizeof(BOOL);
       
   270 				TInt err = iWin32Socket.GetOption(IPPROTO_TCP, TCP_NODELAY, (char*)&bOptVal, &length);
       
   271 				if (err == KErrNone)
       
   272 					{
       
   273 					TPckg<TInt> intPackage(bOptVal);
       
   274 					anOption.Copy(intPackage);
       
   275 					}
       
   276 				return err;
       
   277 				}
       
   278 			}
       
   279 		}
       
   280 
       
   281 	return CWinSockProviderBase::GetOption(aLevel, aName, anOption);
       
   282 	}
       
   283 
       
   284 TInt CWinSockTcpProvider::SetOption(TUint aLevel, TUint aName, const TDesC8& anOption)
       
   285 	{
       
   286 	if (aLevel == KSolInetTcp)
       
   287 		{
       
   288 		switch (aName)
       
   289 			{
       
   290 			case KSoTcpNoDelay:
       
   291 				{
       
   292 				TPckgC<TInt> intPackage(0);
       
   293 				intPackage.Set(anOption);
       
   294 				BOOL bOptVal = intPackage();
       
   295 				return iWin32Socket.SetOption(IPPROTO_TCP, TCP_NODELAY, (char*)&bOptVal, sizeof(BOOL));
       
   296 				}
       
   297 			}
       
   298 		}
       
   299 
       
   300 	return CWinSockProviderBase::SetOption(aLevel, aName, anOption);
       
   301 	}
       
   302 
       
   303 void CWinSockTcpProvider::HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError)
       
   304 	{
       
   305 	switch (aRequestType)
       
   306 		{
       
   307 		case MWin32SocketObserver::EConnect:
       
   308 			{
       
   309 			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: EConnect, error: %d"), aError));
       
   310 			if (aError)
       
   311 				{
       
   312 				iSocket->Error(aError, MSocketNotify::EErrorConnect);
       
   313 				}
       
   314 			else
       
   315 				{
       
   316 				StartReceive();
       
   317 				if (iSocket)
       
   318 					{
       
   319 					iSocket->ConnectComplete();
       
   320 					}
       
   321 				}
       
   322 			break;
       
   323 			}
       
   324 		case MWin32SocketObserver::ESend:
       
   325 			{
       
   326 			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: ESend, error: %d"), aError));
       
   327 			if (iSocket)
       
   328 				{
       
   329 				if (aError)
       
   330 					{
       
   331 					iSocket->Error(aError, MSocketNotify::EErrorSend);
       
   332 					}
       
   333 				else
       
   334 					{
       
   335 					iSocket->CanSend();
       
   336 					}
       
   337 				}
       
   338 			break;
       
   339 			}
       
   340 		case MWin32SocketObserver::EReceive:
       
   341 			{
       
   342 			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: EReceive, error: %d"), aError));
       
   343 			if (aError)
       
   344 				{
       
   345 				if (iSocket)
       
   346 					{
       
   347 					iSocket->Error(aError, MSocketNotify::EErrorRecv);
       
   348 					}
       
   349 				}
       
   350 			else
       
   351 				{
       
   352 				iEsockReadBuffer.Set(iWinSockWriteBuffer);
       
   353 				TInt receivedBytes = iEsockReadBuffer.Length();
       
   354 				WSP_LOG(WspLog::Printf(_L("\t %d bytes received"), receivedBytes));
       
   355 				if (iSocket)
       
   356 					{
       
   357 					if (receivedBytes)
       
   358 						{
       
   359 						iSocket->NewData(receivedBytes);
       
   360 						}
       
   361 					else
       
   362 						{
       
   363 						iSocket->NewData(KNewDataEndofData);
       
   364 						}
       
   365 					}
       
   366 				}
       
   367 			break;
       
   368 			}
       
   369 		case MWin32SocketObserver::EAccept:
       
   370 			{
       
   371 			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: EAccept, error: %d"), aError));
       
   372 			iAcceptSap->StartReceive();
       
   373 			CWinSockProviderBase& acceptSap = *iAcceptSap;
       
   374 			iAcceptSap = NULL;	// This pointer will be reused when our HandleListeningSapStarted gets, which may be as a result of the next CSocket::ConnectComplete call.
       
   375 			iSocket->ConnectComplete(acceptSap);
       
   376 			break;
       
   377 			}
       
   378 		case MWin32SocketObserver::ESendTo:
       
   379 		case MWin32SocketObserver::EReceiveFrom:
       
   380 		default:
       
   381 			{
       
   382 			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidTcpSocketRequestType));
       
   383 			}
       
   384 		}
       
   385 	}
       
   386 
       
   387 void CWinSockTcpProvider::DoPassiveOpenL(TUint aQue)
       
   388 	{
       
   389 	__ASSERT_DEBUG(iAcceptSap == NULL, Panic(EWinSockPrtCWinSockTcpProviderDoPassiveOpenLAcceptSapNotNull));
       
   390 	CWinSockTcpProvider* acceptSap = CWinSockTcpProvider::NewBlankLC(iWin32Factory);
       
   391 	acceptSap->SetListeningSap(*this);
       
   392 	User::LeaveIfError(iWin32Socket.Listen(aQue));
       
   393 	User::LeaveIfError(iAcceptSocketWrapper->Accept(acceptSap->iWin32Socket));
       
   394 	CleanupStack::Pop(acceptSap);
       
   395 	iAcceptSap = acceptSap;
       
   396 	}
       
   397 
       
   398 void CWinSockTcpProvider::StartReceive()
       
   399 	{
       
   400 	iWinSockWriteBuffer.Zero();
       
   401 	iReceiveSocketWrapper->Receive(iWinSockWriteBuffer);
       
   402 	}
       
   403 
       
   404 void CWinSockTcpProvider::SetListeningSap(CWinSockTcpProvider& aListeningSap)
       
   405 	{
       
   406 	__ASSERT_DEBUG(iListeningSap == NULL, Panic(EWinSockPrtCWinSockTcpProviderSetListeningSapAlreadySet));
       
   407 	iListeningSap = &aListeningSap;
       
   408 	}
       
   409 
       
   410 void CWinSockTcpProvider::HandleListeningSapStarted()
       
   411 	{
       
   412 	__ASSERT_DEBUG(iAcceptSap == NULL, Panic(EWinSockPrtCWinSockTcpProviderStartAcceptSapNotNull));
       
   413 	CWinSockTcpProvider* acceptSap = CWinSockTcpProvider::NewBlankLC(iWin32Factory);
       
   414 	acceptSap->SetListeningSap(*this);
       
   415 	User::LeaveIfError(iAcceptSocketWrapper->Accept(acceptSap->iWin32Socket));
       
   416 	CleanupStack::Pop(acceptSap);
       
   417 	iAcceptSap = acceptSap;
       
   418 	}
       
   419 
       
   420 
       
   421 //
       
   422 // CWinSockUdpProvider.
       
   423 //
       
   424 
       
   425 CWinSockUdpProvider* CWinSockUdpProvider::NewL(RWin32Factory& aWin32Factory)
       
   426 	{
       
   427 	CWinSockUdpProvider* self = new(ELeave) CWinSockUdpProvider(aWin32Factory);
       
   428 	CleanupStack::PushL(self);
       
   429 	self->ConstructL();
       
   430 	CleanupStack::Pop(self);
       
   431 	return self;
       
   432 	}
       
   433 
       
   434 TInt CWinSockUdpProvider::SetLocalName(TSockAddr& anAddr)
       
   435 	{
       
   436 	TInt err = CWinSockProviderBase::SetLocalName(anAddr);
       
   437 	if (err == KErrNone)
       
   438 		{
       
   439 		iReceiveSocketWrapper->ReceiveFrom(iWinSockWriteBuffer, iReceiveFromAddress);
       
   440 		}
       
   441 	return err;
       
   442 	}
       
   443 
       
   444 void CWinSockUdpProvider::RemName(TSockAddr& anAddr) const
       
   445 	{
       
   446 	anAddr = iRemoteAddr;
       
   447 	}
       
   448 
       
   449 TUint CWinSockUdpProvider::Write(const TDesC8& aDesc, TUint /*options*/, TSockAddr* anAddr)
       
   450 	{
       
   451 	WSP_LOG(WspLog::Printf(_L("CWinSockUdpProvider::Write: writing %d bytes"), aDesc.Length()));
       
   452 	WSP_RAW_LOG(WspLog::WriteRawOutbound(aDesc));
       
   453 	if (iSendSocketWrapper->IsActive())
       
   454 		{
       
   455 		return 0;
       
   456 		}
       
   457 	TInt err = FillSendBuffer(aDesc);
       
   458 	if (err)
       
   459 		{
       
   460 		iSocket->Error(err, MSocketNotify::EErrorSend);
       
   461 		return 0;
       
   462 		}
       
   463 	if (anAddr)
       
   464 		{
       
   465 		iSendSocketWrapper->SendTo(*iSendBuffer, *anAddr);
       
   466 		}
       
   467 	else
       
   468 		{
       
   469 		iSendSocketWrapper->SendTo(*iSendBuffer, iRemoteAddr);
       
   470 		}
       
   471 	return iSendBuffer->Length();
       
   472 	}
       
   473 
       
   474 void CWinSockUdpProvider::GetData(TDes8 &aDesc, TUint /*aOptions*/, TSockAddr* anAddr)
       
   475 	{
       
   476 	WSP_LOG(WspLog::Write(_L("CWinSockUdpProvider::GetData")));
       
   477 	TInt esockBufferSize = aDesc.Length();
       
   478 	if (esockBufferSize >= iEsockReadBuffer.Length())
       
   479 		{
       
   480 		WSP_LOG(WspLog::Printf(_L("\tCopying all %d bytes up to ESock"), iEsockReadBuffer.Length()));
       
   481 		aDesc.Copy(iEsockReadBuffer);
       
   482 		}
       
   483 	else
       
   484 		{
       
   485 		WSP_LOG(WspLog::Printf(_L("\tESock buffer size: %d, available data: %d"), esockBufferSize, iEsockReadBuffer.Length()));
       
   486 		aDesc.Copy(iEsockReadBuffer.Left(esockBufferSize)); // Throw away remainder.
       
   487 		}
       
   488 
       
   489 	WSP_RAW_LOG(WspLog::WriteRawInbound(aDesc));
       
   490 
       
   491 	if (anAddr)
       
   492 		{
       
   493 		anAddr->Copy(iReceiveFromAddress);
       
   494 		}
       
   495 	iWinSockWriteBuffer.Zero();
       
   496 	iReceiveSocketWrapper->ReceiveFrom(iWinSockWriteBuffer, iReceiveFromAddress);
       
   497 	}
       
   498 
       
   499 void CWinSockUdpProvider::Start()
       
   500 	{
       
   501 	}
       
   502 
       
   503 void CWinSockUdpProvider::ActiveOpen(void)
       
   504 	{
       
   505 	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWinSockUdpProviderActiveOpenUnexpectedCall));
       
   506 	}
       
   507 
       
   508 TInt CWinSockUdpProvider::PassiveOpen(TUint /*aQue*/)
       
   509 	{
       
   510 	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWinSockUdpProviderPassiveOpenUnexpectedCall));
       
   511 	return 0;
       
   512 	}
       
   513 
       
   514 void CWinSockUdpProvider::HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError)
       
   515 	{
       
   516 	switch (aRequestType)
       
   517 		{
       
   518 		case MWin32SocketObserver::ESendTo:
       
   519 			{
       
   520 			WSP_LOG(WspLog::Printf(_L("CWinSockUdpProvider::HandleWin32SocketCompletion: ESendTo, error: %d"), aError));
       
   521 			if (aError)
       
   522 				{
       
   523 				iSocket->Error(aError, MSocketNotify::EErrorSend);
       
   524 				}
       
   525 			else
       
   526 				{
       
   527 				iSocket->CanSend();
       
   528 				}
       
   529 			break;
       
   530 			}
       
   531 		case MWin32SocketObserver::EReceiveFrom:
       
   532 			{
       
   533 			WSP_LOG(WspLog::Printf(_L("CWinSockUdpProvider::HandleWin32SocketCompletion: EReceiveFrom, error: %d"), aError));
       
   534 			if (aError)
       
   535 				{
       
   536 				iSocket->Error(aError, MSocketNotify::EErrorRecv);
       
   537 				}
       
   538 			else
       
   539 				{
       
   540 				iEsockReadBuffer.Set(iWinSockWriteBuffer);
       
   541 				WSP_LOG(WspLog::Printf(_L("\t %d bytes received"), iEsockReadBuffer.Length()));
       
   542 				iSocket->NewData(1);
       
   543 				}
       
   544 			break;
       
   545 			}
       
   546 		case MWin32SocketObserver::EConnect:
       
   547 		case MWin32SocketObserver::ESend:
       
   548 		case MWin32SocketObserver::EReceive:
       
   549 		case MWin32SocketObserver::EAccept:
       
   550 		default:
       
   551 			{
       
   552 			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidUdpSocketRequestType));
       
   553 			}
       
   554 		}
       
   555 	}
       
   556 
       
   557 CWinSockUdpProvider::~CWinSockUdpProvider()
       
   558 	{
       
   559 	}
       
   560 
       
   561 CWinSockUdpProvider::CWinSockUdpProvider(RWin32Factory& aWin32Factory)
       
   562 	: CWinSockProviderBase(aWin32Factory)
       
   563 	{
       
   564 	}
       
   565 
       
   566 void CWinSockUdpProvider::ConstructL()
       
   567 	{
       
   568 	User::LeaveIfError(iWin32Socket.Open(iWin32Factory, RWin32Socket::EUdp));
       
   569 	CWinSockProviderBase::ConstructL();
       
   570 	}