×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    444

    Issue with TCP/IP socket

    Hello,

    I am facing issues with TCP/IP socket.
    I am connecting my device to the remote server using RSocket.
    For that we have created two AOs for reading and writing to socket.
    The write AO activated only when there is a need to send the data, while the read AO is activated all the time.
    While I am sending the packets continuously to server, after some packets sent the read active object ends with KErrWrite.

    My code for read AO RunL() is as follow:
    Code:
    void CClientRead::RunL()
    {
    	if (iStatus == KErrNone)
    	// Buffer has been read from socket
    	{
    		switch(iReadStatus)
    		{
    			case EReadingHeader:
    				{
    					memcpy(&iHeader,iPtrBuffer.Ptr(),sizeof(Header));
    					int datalength = htonl(iHeader.length);
    					
    					iCurrentDataLength = datalength;
    					TInt dataread = iDataRec();
    					iCurrentDataLength -= (dataread - sizeof(Header));
    					
    					User::LeaveIfError(iCurrentPacket.Replace(CCoeEnv::Static()->FsSession(),iPacketFile,EFileWrite));
    										
    
    					TInt len = iPtrBuffer.Length();
    					len -= sizeof(Header);
    					
    					TPtrC8 pReadBuffer = iPtrBuffer.Right(len);
    
    					iCurrentPacket.Write(pReadBuffer);
    					
    					if(iCurrentDataLength > 0)	
    					{
    						ReadData(iCurrentDataLength);
    					}
    					else
    					{
    						unsigned long lStatus, lContent, lLength;
    						
    						lStatus = htonl(iHeader.status);
    						lContent = htonl(iHeader.content);
    						lLength = htonl(iHeader.length);
    						
    						iCurrentPacket.Close();					
    						if(iUI) iUI->ReadNotify(lStatus, lContent, lLength , pReadBuffer);
    						IssueRead();
    					}
    				} 
    				break;
    			case EReadingData:
    				{
    					unsigned long lStatus, lContent, lLength;
    							
    					lStatus = htonl(iHeader.status);
    					lContent = htonl(iHeader.content);
    					lLength = htonl(iHeader.length);
    					TInt dataread = iDataRec();
    					
    					iCurrentDataLength -= dataread;
    					
    					if(iCurrentDataLength > 0)
    					{						
    						iCurrentPacket.Write(iPtrBuffer);
    						ReadData(iCurrentDataLength);
    					}
    					else
    					{
    
    						iCurrentPacket.Write(iPtrBuffer);
    						iCurrentPacket.Close();
    						
    						if(iUI) iUI->ReadNotify(lStatus, lContent, lLength , iPtrBuffer);
    						IssueRead();
    					}
    				}
    				break;
    			default: break;
    			}
    		}
    }
    During issuing write for more than one time the read runl finish with KErrWrite. Help me in this please.

    Regards,
    Kavit.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Issue with TCP/IP socket

    Are you trying to have two active request active same time in one active object, if so, then you can not do it that way, but you would need to have either two active object to handle them, or do just one request at time with one active object.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    444

    Re: Issue with TCP/IP socket

    Hi Yucca,

    Thanks. I have two Active objects, one for reading and one for writing.


    Regards,
    Kavit.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Issue with TCP/IP socket

    So then you can not have them active same time in one active object..

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    444

    Re: Issue with TCP/IP socket

    Quote Originally Posted by symbianyucca View Post
    So then you can not have them active same time in one active object..
    Hello Yucca,

    I have two separate active objects (thus two different class) for reading and writing.


    Regards,
    Kavit.

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    444

    Re: Issue with TCP/IP socket

    I am using the Socket example for TCP/IP from
    Examples\networking\tcpip\echoclientengine

    We are transferring xml packets between client and server. So We had modified the code in that source.
    When we are going to transfer a file-- large in size, in multiple chunks, after some chunks being transferred I am facing KErrWrite for the read AO RunL.

    Regards,
    Kavit.

  7. #7
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    135

    tcp/ip reading and writing

    i am implementing tcp/ip socket to sent xml data to server

    i have implement it using active object

    start() to connect to socket


    and in Runl(){
    EConnecting:

    write();

    and

    read

    and

    socket closed


    problem is that seperate reading and writing is allowed but

    reading and writing is not allowed continueously

    after that i have closed connection

    can any body suggest me what is problem

    should i implement in seperate active for reading and writing

  8. #8
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Re: Issue with TCP/IP socket

    Hi,
    Though i am new to Symbian C++ but i have had a good amount of experience in J2me. I was reading a lot about processes ,threads and Active objects in Symbian c++. So as far as i can see .reading and writing continuously are two separate processes (please correct me if i am wrong). and in one application there can be only one active scheduler. Now we can have many active objects in the scheduler but if any of the RunL() methods has some loop that is endless then in that case the ActiveScheduler() will not pass the handler to the other active objects and then the reading/writing or whatever is there in the RunL() of other active objects will not take place. And as we cannot have more then one activeScheduler in one application i think Using seperate threads using RThread() for these processes are the only way.
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,697

    Re: Issue with TCP/IP socket

    It is true that one active object can wait for one event at a time. Thus you should use two active objects. The RSocket object will not notice the trick, I promise.

  10. #10
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    135

    Re: Issue with TCP/IP socket

    Quote Originally Posted by wizard_hu_ View Post
    It is true that one active object can wait for one event at a time. Thus you should use two active objects. The RSocket object will not notice the trick, I promise.
    thanks for response

    but i dont know how it is actually going to implement to implement for reading and writing


    can i have some suggestion from your side how to call two active object RunL() methods

  11. #11
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Issue with TCP/IP socket

    you could maybe download 2nd edition SDKs, and find a sockets example from it, it would have full example on the topic.

  12. #12
    Registered User
    Join Date
    Feb 2011
    Location
    Islamabad, Pakistan
    Posts
    73

    Re: Issue with TCP/IP socket

    Hi Dear Yucca,
    I have download and understood sockets and TCP/IP echoengine examples from SDK 2nd Ed, FP3 but How to run, compile and build these examples of SDK 2nd Ed, FP3 on SDK 3rd Ed, FP2? I am getting error "undefined identifier 'TDllReason' in sockets.cpp due to

    GLDEF_C TInt E32Dll( TDllReason )
    {
    return KErrNone;
    }

    Mr. Wizard has provided me very good hint on it and i have started working on it too.
    "E32Dll is S60 2nd edition stuff (applications were dll-s that time), you do not need this method.
    You can find a porting guide: Resources above, Documentation, Symbian C++, Compatibility.
    The most essential steps are also described in #2 of http://www.developer.nokia.com/Commu...t-start-at-all"
    Do you have more on it as you worked actually on these two examples.

    Thanks and Regards
    awais qureshi

Similar Threads

  1. The TCP/IP issue in real time
    By Ronak_86 in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2008-12-16, 04:05
  2. Socket Recvfrom Issue
    By jayantjain in forum Open C/C++
    Replies: 1
    Last Post: 2008-10-29, 10:50
  3. Porting issue related to socket
    By muralidharvvk in forum Symbian
    Replies: 4
    Last Post: 2007-03-08, 14:18
  4. RTSP video streaming issue on 6280
    By olivier_irac in forum General Development Questions
    Replies: 0
    Last Post: 2006-12-04, 15:11
  5. Socket TCP/IP data transmission failed..on 6680
    By yilunyou in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2006-11-19, 04:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×