예제 #1
0
파일: sock.c 프로젝트: AmoebaLabs/pjsip
static int connect_test()
{
	RSocketServ rSockServ;
	RSocket rSock;
	TInetAddr inetAddr;
	TRequestStatus reqStatus;
	char buffer[16];
	TPtrC8 data((const TUint8*)buffer, (TInt)sizeof(buffer));
 	int rc;
	
	rc = rSockServ.Connect();
	if (rc != KErrNone)
		return rc;
	
	rc = rSock.Open(rSockServ, KAfInet, KSockDatagram, KProtocolInetUdp);
    	if (rc != KErrNone) 
    	{    		
    		rSockServ.Close();
    		return rc;
    	}
   	
    	inetAddr.Init(KAfInet);
    	inetAddr.Input(_L("127.0.0.1"));
    	inetAddr.SetPort(80);
    	
    	rSock.Connect(inetAddr, reqStatus);
    	User::WaitForRequest(reqStatus);

    	if (reqStatus != KErrNone) {
		rSock.Close();
    		rSockServ.Close();
		return rc;
    	}
    
    	rSock.Send(data, 0, reqStatus);
    	User::WaitForRequest(reqStatus);
    	
    	if (reqStatus!=KErrNone) {
    		rSock.Close();
    		rSockServ.Close();
    		return rc;
    	}
    	
    	rSock.Close();
    	rSockServ.Close();
	return KErrNone;
}
TVerdict CmoveConnectedSocketToSubconnectionStep::doSingleTestStep()
	{
	
	RSocket			socket;
	TInetAddr		dstAddr;
	RSocketServ		socketServer;
	RConnection		conn;
	RSubConnection	subconn;
	TRequestStatus	status;
	TRequestStatus 	eventStatus;
	TNotificationEventBuf	subconnNotifBuf;
	TInt				ret;
	
	CleanupClosePushL(socketServer);
   	CleanupClosePushL(conn);
    	CleanupClosePushL(socket);
    	CleanupClosePushL(subconn);

    	// Connect to ESOCK
    	ret = socketServer.Connect();
    	if (ret != KErrNone)
    		{
    		INFO_PRINTF2(_L("Failed to connect toEsock due to Error: %d."),ret);
    		return EFail;
    		}
  
        	// Open a connection
    	ret = conn.Open(socketServer);
	if (ret != KErrNone)
    		{
    		INFO_PRINTF2(_L("Failed to open connection due to Error: %d."),ret);
    		return EFail;
    		}

	// Start the connection
	conn.Start(status);
	User::WaitForRequest(status);
	
	if (status != KErrNone)
    		{
    		INFO_PRINTF2(_L("Failed to start connection due to Error: %d."),status.Int());
    		return EFail;
    		}


	// Open UDP socket
	ret = socket.Open(socketServer,
			KAfInet,
	                      KSockDatagram,
	                      KProtocolInetUdp,
	                      conn);
	if (ret != KErrNone)
    		{
    		INFO_PRINTF2(_L("Failure to open socket due to Error: %d."),ret);
    		return EFail;
    		}
	
	
	dstAddr.SetPort(3441);
	_LIT(KText50, "127.0.0.1");
	dstAddr.Input( KText50 );

	ret = socket.SetLocalPort(3442);
	if (ret != KErrNone)
    		{
    		INFO_PRINTF2(_L("Failed to set port on socket due to Error: %d."),ret);
    		return EFail;
    		}
    		
	socket.Connect(dstAddr, status);
	User::WaitForRequest(status);

	if (status != KErrNone)
    		{
    		INFO_PRINTF2(_L("Socket failed to connect to dst addr due to Error: %d."),status.Int());
    		return EFail;
    		}

	// Create a new sub-connection
	ret = subconn.Open(socketServer,
	                   RSubConnection::ECreateNew,
	                   conn);
	if (ret != KErrNone)
    		{
    		INFO_PRINTF2(_L("Failed to create new sub-connection due to Error: %d."),ret);
    		return EFail;
    		}
    		
	 // Move the connected socket onto the new sub-connection
	subconn.Add(socket, status);
	User::WaitForRequest(status);

	if (status != KErrNotReady)
    		{
    		INFO_PRINTF2(_L("Socket could not be added to subconn due to  Error: %d."),status.Int());
    		return EFail;
    		}

	 // close and destroy
	CleanupStack::PopAndDestroy(&subconn);
	CleanupStack::PopAndDestroy(&socket);
	CleanupStack::PopAndDestroy(&conn);
	CleanupStack::PopAndDestroy(&socketServer);
	
 	return EPass;
	}
예제 #3
0
// Main 
void MainL()
	{
	/* Inetd Setup 
	Create a inetd process 
	*/
	RProcess inetd;
	CleanupClosePushL(inetd);
	User::LeaveIfError(inetd.Create(_L("inetd"), _L("")));
	
	// Resume inetd
	inetd.Resume();
	
	// Wait for inetd to be ready
	console->Printf(_L("[ press any key ]"));
	console->Getch();	// Get and ignore character

	
	/* IPEcho Part 
	Connect to socket server 
	*/
	console->Printf(_L("Connect to socket server ... \n"));
	RSocketServ socketServ;
	CleanupClosePushL(socketServ);
	User::LeaveIfError(socketServ.Connect());
	
	// Open RConnection
	console->Printf(_L("Open RConnection ... \n"));
	RConnection connect;
	CleanupClosePushL(connect);
	User::LeaveIfError(connect.Open(socketServ, KConnectionTypeDefault));

	// Start RConnection
	console->Printf(_L("Start RConnection ... \n"));
	TCommDbConnPref prefs;
	prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	User::LeaveIfError(connect.Start(prefs));	// Handle options here like (ie: No Prompt)

	// Open RSocket
	console->Printf(_L("Open Socket ... \n"));
	RSocket sock;
	CleanupClosePushL(sock);
	User::LeaveIfError(sock.Open(socketServ, KAfInet, KSockStream, KProtocolInetTcp, connect));

	// Connect
	console->Printf(_L("Connect Socket ... \n"));
	TRequestStatus status;
	TInetAddr echoServAddr(KInetAddrLoop, 7);	// 7: TCP port 
	sock.Connect(echoServAddr, status);
	User::WaitForRequest(status);
	User::LeaveIfError(status.Int());

	// Wait for the socket transfer to be over 
	console->Printf(_L("[ press any key ]"));
	console->Getch();	// Get and ignore character
	
	// Send a packet
	console->Printf(_L("Send a packet ... \n"));
	HBufC8* packet = HBufC8::NewL(KSocketDefaultBufferSize);
	CleanupStack::PushL(packet);

	packet->Des().SetMax();
	packet->Des().FillZ();
	sock.Send(packet->Des(), 0, status);
	User::WaitForRequest(status);
	User::LeaveIfError(status.Int());
	
	// Receive it back
	console->Printf(_L("Received it back ... \n"));
	packet->Des().Zero();
	TPtr8 buff = packet->Des();
	sock.Recv(buff, 0, status);
	User::WaitForRequest(status);
	User::LeaveIfError(status.Int());

	
	// Terminates 
	console->Printf(_L("Terminates ... \n"));
	CleanupStack::PopAndDestroy(packet);
	CleanupStack::PopAndDestroy(&sock);
	CleanupStack::PopAndDestroy(&connect);
	CleanupStack::PopAndDestroy(&socketServ);
	CleanupStack::PopAndDestroy(&inetd);
	}
예제 #4
0
TVerdict CPPPMinMaxMMU::doTestStepL()
	{
	const TInt KMaxMMU = 4000;
	const TInt KMinMMU = 1;

	TBuf8<KMaxMMU> *sendBuf = new(ELeave) TBuf8<KMaxMMU>();
	CleanupStack::PushL(sendBuf);
	
	TBuf8<KMaxMMU> *recvBuf = new(ELeave) TBuf8<KMaxMMU>();
	CleanupStack::PushL(recvBuf);
	
	TBuf8<KMaxMMU> *recvBuf2 = new(ELeave) TBuf8<KMaxMMU>();
	CleanupStack::PushL(recvBuf2);

    //initialize COMM
    //CommInitL(EFalse);
    
	//Start Comms server
// 	_LIT(KPhbkSyncCMI, "phbsync.cmi");
//    (void)StartC32WithCMISuppressions(KPhbkSyncCMI);
	
	SetTestStepResult(EPass);
    INFO_PRINTF1(_L("Starting: Socket Server\n"));
    
    RSocketServ ss;

    // Start the socket server
    TEST(KErrNone == ss.Connect());
    RSocket sock;
    TRequestStatus sta;
	INFO_PRINTF1(_L("Open a socket\n"));
    
    // Get the test address
    TInetAddr RemAddr(7);
    TPtrC testAddr;
	TEST(GetStringFromConfig(_L("AddressInfo"), _L("TestPPPIPAddr"), testAddr));
	
    if(testAddr.Length())
		{
		RemAddr.Input(testAddr); 
		}
    else
		{
		INFO_PRINTF1(_L("Test FAILED\nMissing address information in config file: "));
		return EFail;
		}
    
    // Open a socket
    TEST(KErrNone == sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp)); 
    INFO_PRINTF1(_L("Connecting Socket to:"));
	
    TBuf<30> printAddr;
    RemAddr.Output(printAddr);
	
    INFO_PRINTF1(printAddr);
	
    // Connect a socket
    sock.Connect(RemAddr,sta);
	
    // Wait for Connect to complete
    User::WaitForRequest(sta);
    TEST(sta.Int() == 0);
    
    TInt iterEnd;
	GetIntFromConfig(_L("MMUInfo"), _L("TestPPPmaxMMU"), iterEnd);
    if (iterEnd > KMaxMMU)
		iterEnd = KMaxMMU;
	
    TInt iterStart;
	GetIntFromConfig(_L("MMUInfo"), _L("TestPPPminMMU"), iterStart);
    if (iterStart < KMinMMU)
		iterStart = KMinMMU;
	
    TInt i,j;
    TSockXfrLength recvLen;
    INFO_PRINTF1(_L("Send/Recv frames"));
    for(j=iterStart;j<=iterEnd;j++)
		{
		sendBuf->Zero();
		
		for (i=0;i<j;i++)
			sendBuf->Append(Math::Random() & 0x7f);
		
		INFO_PRINTF2(_L("Sending Packet of Size: %d"),j);
		// Send data to echo port
		sock.Write(*sendBuf,sta);
		User::WaitForRequest(sta);
		TEST(sta.Int() == 0);
		i=0;
		recvBuf->Zero();
		
		while(i<j)
			{
			// Receive data from echo port
			sock.RecvOneOrMore(*recvBuf2,0,sta,recvLen); 
			User::WaitForRequest(sta);
			TEST(sta.Int() == 0);
			i += recvBuf2->Length();
			recvBuf->Append(*recvBuf2);
			}
		
		TEST(KErrNone == recvBuf->Compare(*sendBuf));
		INFO_PRINTF1(_L("   Received echoed Packet"));
		}
    
    sock.Shutdown(RSocket::EStopOutput,sta);
    User::WaitForRequest(sta);
    TEST(sta.Int() == 0);
    sock.Close();
    ss.Close();

	CleanupStack::PopAndDestroy(3);

	return TestStepResult();
	}
예제 #5
0
SilcStream silc_net_udp_connect(const char *local_ip_addr, int local_port,
				const char *remote_ip_addr, int remote_port,
				SilcSchedule schedule)
{
  SilcSymbianSocket *s;
  SilcStream stream;
  TInetAddr local, remote;
  TRequestStatus status;
  RSocket *sock = NULL;
  RSocketServ *ss = NULL;
  TInt ret;

  SILC_LOG_DEBUG(("Creating UDP stream"));

  if (!schedule) {
    schedule = silc_schedule_get_global();
    if (!schedule) {
      silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
      goto err;
    }
  }

  SILC_LOG_DEBUG(("Binding to local address %s",
		  local_ip_addr ? local_ip_addr : "0.0.0.0"));

  sock = new RSocket;
  if (!sock)
    goto err;

  ss = new RSocketServ;
  if (!ss)
    goto err;

  /* Open socket server */
  ret = ss->Connect();
  if (ret != KErrNone)
    goto err;

#ifdef SILC_THREADS
  /* Make our socket shareable between threads */
  ss->ShareAuto();
#endif /* SILC_THREADS */

  /* Get local bind address */
  if (!silc_net_set_sockaddr(&local, local_ip_addr, local_port))
    goto err;

  /* Create the socket */
  ret = sock->Open(*ss, KAfInet, KSockDatagram, KProtocolInetUdp);
  if (ret != KErrNone) {
    SILC_LOG_ERROR(("Cannot create socket"));
    goto err;
  }

  /* Set the socket options */
  sock->SetOpt(KSoReuseAddr, KSolInetIp, 1);

  /* Bind the listener socket */
  ret = sock->Bind(local);
  if (ret != KErrNone) {
    SILC_LOG_DEBUG(("Cannot bind socket"));
    goto err;
  }

  /* Set to connected state if remote address is provided. */
  if (remote_ip_addr && remote_port) {
    if (silc_net_set_sockaddr(&remote, remote_ip_addr, remote_port)) {
      sock->Connect(remote, status);
      if (status != KErrNone) {
	SILC_LOG_DEBUG(("Cannot connect UDP stream"));
	goto err;
      }
    }
  }

  /* Encapsulate into socket stream */
  s = silc_create_symbian_socket(sock, ss);
  if (!s)
    goto err;
  stream =
    silc_socket_udp_stream_create((SilcSocket)s, local_ip_addr ?
				  silc_net_is_ip6(local_ip_addr) : FALSE,
				  remote_ip_addr ? TRUE : FALSE, schedule);
  if (!stream)
    goto err;

  SILC_LOG_DEBUG(("UDP stream created, fd=%d", sock));
  return stream;

 err:
  if (sock)
    delete sock;
  if (ss) {
    ss->Close();
    delete ss;
  }
  return NULL;
}
enum TVerdict CEsockTest29_11::easyTestStepL( void )
	{
	TVerdict verdict = EFail;
	TInt ret;
	
	Logger().WriteFormat(_L("Send/ Recv on PDummy3 socket but no avail MBuf Memory, mBuf becomes avail after send"));
	RSocketServ ss;
	ret = ss.Connect();
	TESTL(KErrNone == ret);	
	CleanupClosePushL(ss);
    
    // open dummy prot 3
	Logger().WriteFormat(_L("Openning Dummy Protocol 3"));             
	RSocket sock;                                                  
	ret = sock.Open(ss,_L("Dummy Protocol 3"));
	TESTL(KErrNone == ret);
	
	// connecti socket
	TSockAddr addr;
	TRequestStatus stat;
	sock.Connect(addr, stat);
	User::WaitForRequest(stat);
	TESTL(KErrNone == stat.Int());	
	
	// drain MBuf Pool
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);
	
	// send data and wait for 1/10 seconds
	Logger().WriteFormat(_L("Sending Data"));     
	_LIT8( sendData, "bla bla bla bla");        
	sock.Send(sendData,0,stat);
	const TUint KTenMilliSecs = 10000; 
	User::After(KTenMilliSecs);
	
	// free all mbufs
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetFreeMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetFreeMBufs, 0, 0);
	TESTL(ret == KErrNone);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);

	// wait for send to return
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Send has returned %d"), stat.Int());
	if(stat.Int() != KErrNone)
		{
		verdict = EFail;
		}
	
	// recieve data and verify that it is the same as send data
	TBuf8<20> recvBuf;
	TRequestStatus recvStatus;
	sock.Recv(recvBuf, 0, recvStatus);
	User::WaitForRequest(recvStatus);
	Logger().WriteFormat(_L("recieving data on PDummy3 has returned %d"), recvStatus.Int());
	if(recvStatus.Int() != KErrNone)
		{
		verdict = EFail;
		}
	Logger().WriteFormat(_L("Comparing Recieved data and Sent data"), recvStatus.Int());		
	if(recvBuf.Compare(sendData) == 0)
		{
		verdict = EPass; 
		}
	
	sock.Close();
	CleanupStack::PopAndDestroy(&ss);
    SetTestStepResult(verdict);
	return verdict;

	}
enum TVerdict CEsockTest29_10::easyTestStepL( void )
	{
	SetTestStepResult(EFail);
	TInt ret;
	const TUint KOneSecond = 1000000;
	
	Logger().WriteFormat(_L("Send/ Recv on PDummy3 socket but no avail MBuf Memory, mBuf becomes avail after send"));
	RSocketServ ss;
	ret = ss.Connect();
	TESTL(KErrNone == ret);	
    
    // open dummy prot 3
	Logger().WriteFormat(_L("Openning Dummy Protocol 3"));             
	RSocket sock;                                                  
	ret = sock.Open(ss,_L("Dummy Protocol 3"));
	TESTL(KErrNone == ret);
	
	// connect socket
	TSockAddr addr;
	TRequestStatus connStat;
	sock.Connect(addr, connStat);
	User::WaitForRequest(connStat);
	TESTL(KErrNone == connStat.Int());
	
	// send packet 1
	TRequestStatus stat;
	Logger().WriteFormat(_L("Attempting to create a packet to receive later"));	
	_LIT8(sendDataOne, "First Send");
	sock.Send(sendDataOne,0,stat);
	User::WaitForRequest(stat);
	TESTL(KErrNone == stat.Int());	
	// wait for packets to go through esock
	User::After(KOneSecond * 2);
	// gobble mBufs
	TInt nFree = 0;
	sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
	while (nFree > 0)
		{
		ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
		sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
		}
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
	
	// we are running in high priority and allocating in a loop.
	// so kernel may not be able to enlarge the pools.
	// wait for kernel to enlarge the pool
	// We have to come out from the loop as well.
    User::After(KOneSecond * 2);
	
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetGobbleMBufs returned %d"), ret);
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }
    // Once again
    User::After(KOneSecond * 2);
    sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
    Logger().WriteFormat(_L("Attempting to set KDummyOptionSetGobbleMBufs Option in Protocol"));
    while (nFree > 0)
        {
        ret = sock.SetOpt(KDummyOptionSetGobbleMBufs, 0, 0);
        sock.GetOpt(KDummyOptionGetMBufFreeSpace, 0, nFree);
        }

	
	// send packet 2
	User::After(KOneSecond);
	TRequestStatus stat2;
	_LIT8(sendDataTwo, "Second Send");
	Logger().WriteFormat(_L("Sending Data - Should never complete"));             
	sock.Send(sendDataTwo,0,stat2);

	User::After(KOneSecond);
	Logger().WriteFormat(_L("Now cancel the Send"));     
	sock.CancelSend();
	User::WaitForRequest(stat2);
	TESTL(stat2 == KErrCancel);
	
	Logger().WriteFormat(_L("Receiving Data -- expected to pick up sendDataOne"));
	TBuf8<100> buf;          
	TRequestStatus stat3;
	sock.Recv(buf, 0, stat3);
	User::After(KOneSecond);
	User::WaitForRequest(stat3);
	TESTL(buf.Compare(sendDataOne) == 0);
		
	// send packet 3
	_LIT8(sendDataThree, "Third Send");
	Logger().WriteFormat(_L("Sending Data ... again"));             
	TRequestStatus stat4;
	sock.Send(sendDataThree,0,stat4);
	User::After(1000);
			
	// free memory
	Logger().WriteFormat(_L("Now free memory - should get send and receive completion"));	
	Logger().WriteFormat(_L("Attempting to set KDummyOptionSetFreeMBufs Option in Protocol"));	
	ret = sock.SetOpt(KDummyOptionSetFreeMBufs, 0, 0);
	Logger().WriteFormat(_L("Socket::SetOpt KDummyOptionSetFreeMBufs returned %d"), ret);
	TESTL(KErrNone == ret);	

	Logger().WriteFormat(_L("Sending Data - Should now complete"));             
	User::WaitForRequest(stat4);
	TESTL(stat4.Int() == KErrNone);

	// recieve data and compare contents to sent data
	Logger().WriteFormat(_L("Receiving Data"));
	sock.Recv(buf, 0, stat);
	User::WaitForRequest(stat);
	Logger().WriteFormat(_L("Recv has returned %d"), stat.Int());
	TBuf<100> buf16;
	buf16.Copy(buf);
	if(buf.Compare(sendDataThree) == 0)
		{
		SetTestStepResult(EPass);
		}
		
	Logger().WriteFormat(_L("Data Recv'ed is '%S'"), &buf16);
	sock.Close();
	ss.Close();
	return TestStepResult();
	}
예제 #8
0
enum TVerdict CTestStepLoopback::doTestStepL()
	{
	SetTestStepResult(EFail);
	
//	const TUid KPktTxKey = {0x104045dd};
//	const TUid KPktRxKey = {0x104045de};
//	const TUid KMeUid = {0x101F529F};
//	TSecurityPolicy readPolicy(ECapability_None);
//	TSecurityPolicy writePolicy(ECapability_None);
//	TInt result = RProperty::Define(KMeUid, KPktTxKey .iUid, RProperty::EInt, readPolicy, writePolicy);
//	result = RProperty::Define(KMeUid, KPktRxKey .iUid, RProperty::EInt, readPolicy, writePolicy);
	
	
	RSocketServ ss;
	CleanupClosePushL(ss);
	Logger().WriteFormat(_L("Start: creating + starting connection"));
	User::LeaveIfError(ss.Connect());
	RConnection conn;
	CleanupClosePushL(conn);
	User::LeaveIfError(conn.Open(ss));
	User::LeaveIfError(conn.Start());

	TInt srvPort;
	if(!GetIntFromConfig(_L("TcpLoop"), _L("Port"), srvPort))
		{
		srvPort = 5002;
		}
	Logger().WriteFormat(_L("Start: creating server socket listening on %d"), srvPort);
	RSocket srv;
	CleanupClosePushL(srv);
	User::LeaveIfError(srv.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, conn));
	TInetAddr srvAddr(KAfInet);
	srvAddr.SetPort(srvPort);
	User::LeaveIfError(srv.Bind(srvAddr));
	User::LeaveIfError(srv.Listen(5));
	RSocket acc;
	CleanupClosePushL(acc);
	User::LeaveIfError(acc.Open(ss));
	TRequestStatus accStat;
	srv.Accept(acc, accStat);
	
	Logger().WriteFormat(_L("Start: connecting client socket"));
	RSocket cli;
	CleanupClosePushL(cli);
	User::LeaveIfError(cli.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, conn));
	srvAddr.SetAddress(0xC0A80707);
	TRequestStatus cliStat;
	cli.Connect(srvAddr, cliStat);
	User::WaitForRequest(cliStat, accStat);
	User::WaitForRequest(cliStat, accStat);
	User::LeaveIfError(cliStat.Int());
	User::LeaveIfError(accStat.Int());

	//_LIT8(KTest, "jackdaws love my big sphinx of quartz");
	
	TInt xferSize = 0;
	if(!GetIntFromConfig(_L("TcpLoop"), _L("xferSize"), xferSize))
		{
		xferSize = 1 * 1000 * 1000;
		}
	TInt fc = User::FastCounter();
	TInt txSize = 0;
	TInt txCnt = 0;
	TRequestStatus txStat(KErrNone);
	TBuf8<4096> txBuf;
	txBuf.SetMax();
	TInt rxSize = 0;
	TInt rxCnt = -1;
	TRequestStatus rxStat(KErrNone);
	TBuf8<4096> rxBuf;
	
	Logger().WriteFormat(_L("Transferring %d bytes"), xferSize);
	while(rxSize < xferSize)
		{
		fc = User::FastCounter();
		if(txStat.Int() != KRequestPending)
			{
			RDebug::Printf("tx status:%d, ", txStat.Int());
			cli.Send(txBuf, 0, txStat);
			++txCnt;
			txSize += txBuf.Length();
			RDebug::Printf("tx #%d, %d, +%d\n", txCnt, fc, txBuf.Length());
			}
		if(rxStat.Int() != KRequestPending)
			{
			RDebug::Printf("rx status:%d, ", rxStat.Int());
			++rxCnt;
			rxSize += rxBuf.Length();
			RDebug::Printf("rx #%d, %d, +%d\n", rxCnt, fc, rxBuf.Length());
			TSockXfrLength dummy;
			acc.RecvOneOrMore(rxBuf, 0, rxStat, dummy);
			}
		User::WaitForRequest(rxStat, txStat);
		}
	
	Logger().WriteFormat(_L("Transferred; %d writes, %d reads"), txCnt, rxCnt);
	
//	RProperty::Get(KUidSystemCategory, KPktTxKey .iUid, txCnt);
//	RProperty::Define(KUidSystemCategory, KPktRxKey .iUid, rxCnt);
//	Logger().WriteFormat(_L("Packet counts; %d sends, %d processes"), txCnt, rxCnt);
	
	
	CleanupStack::PopAndDestroy(5, &ss);
	
	SetTestStepResult(EPass);
	return TestStepResult();
	};