Re: udp client crashes on SendTo (S60)
void CSocket_UDPContainerView::Sen_UDP()
{
TBuf8<100> aData;
TRequestStatus astatus;
TInetAddr servAddr;
servAddr.SetAddress(INET_ADDR(111,11,11,111));
servAddr.SetPort(200);
aData.Copy(_L("Test Data"));
socket.SendTo(aData, servAddr, 10, astatus);
SetActive();
User::WaitForRequest(astatus);
}
I changed the code, but it is giving SetActive() undeclared error..
Can anyone suggest how to remove this error - I'm new to active objects
Re: Application Crashing after Receiving few UDP packets
How do i add active object class my class?? Then what must be done to access function such as SetActive() ??
Re: udp client crashes on SendTo (S60)
[QUOTE=Griffolyon-aka-Rick;906332]I'm new to active objects[/QUOTE]
[url]http://www.developer.nokia.com/Community/Wiki/Active_Objects_in_Symbian_OS[/url]
[url]http://www.developer.nokia.com/Community/Wiki/Active_object[/url]
Are you coding a Non-GUI application?
if so, please note that:
[url]http://www.developer.nokia.com/Community/Wiki/How_to_add_Active_Object_to_the_Active_Scheduler[/url]
and from SDK docs, CActiveScheduler needs:
Location: e32base.h
Link against: euser.lib
regards
Re: Application Crashing after Receiving few UDP packets
[QUOTE=Griffolyon-aka-Rick;906336]How do i add active object class my class?? Then what must be done to access function such as SetActive() ??[/QUOTE]
It's not recommended to post the same question twice and resuming an old thread, anyway...:
[url]http://www.developer.nokia.com/Community/Discussion/showthread.php?75069-udp-client-crashes-on-SendTo-(S60)&p=906337&viewfull=1#post906337[/url]
And it's always high recommended to have a look at the very broad Wiki section :-)
regards
pg
Re: udp client crashes on SendTo (S60)
This code is just wrong. SetActive is inseparably paired with iStatus. astatus is your local variable, and you wait for it with User::WaitForRequest anyway.
So remove astatus and use iStatus instead. And also remove the User::WaitForRequest (but keep the SetActive).
(Posts from the old thread are merged here, keep these recent messages in one place)
Re: Application Crashing after Receiving few UDP packets
@pavarang
I'm developing a GUI App
@wizard_hu
I'll try the way u suggested..
Does that mean i can eliminate use of variable aStatus and directly use iStatus?
Re: Application Crashing after Receiving few UDP packets
[QUOTE=Griffolyon-aka-Rick;906410]
Does that mean i can eliminate use of variable aStatus and directly use iStatus?[/QUOTE]
Yes, and you don't need to define iStatus either, its defined for the CActive class already, so you get it when you derive your active object from CActive base class.
Re: Application Crashing after Receiving few UDP packets
I have added CActive to my base class in header file with e32base.h in include also
[B]class CSocket_UDPContainerView : public CAknView, public MExampleTimerNotify, public CActive[/B]
I changed my code to the below and no error is showing in this part of code
void CSocket_UDPContainerView::Sen_UDP()
{
TBuf8<100> aData;
TInetAddr servAddr;
servAddr.SetAddress(INET_ADDR(111,11,11,111));
servAddr.SetPort(200);
aData.Copy(_L("Test Data"));
socket.SendTo(aData, servAddr, 10, iStatus);
SetActive();
}
Now I'm getting an error "no matching function for call to CActive::Active()" at beginning of this function
CSocket_UDPContainerView::CSocket_UDPContainerView()
{
iSocket_UDPContainer = NULL;
udpTimer = NULL;
}
& virtual functions are abstract, cannot allocate an object of type CSocket_UDPContainerView, CBase is an ambigous base of 'CSocket_UDPContainerView' at the first 2 lines of definition
CSocket_UDPContainerView* CSocket_UDPContainerView::NewLC()
{
CSocket_UDPContainerView* self = new ( ELeave ) CSocket_UDPContainerView();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
I think it is due to some wrong initialization of active scheduler. I tried different ways mentioned in the docs you have suggested but with no results
Can you help me to get things right..
Re: Application Crashing after Receiving few UDP packets
You should not derive the CActive in the same class that you do CAknView, instead do move thye active objects stuff into a new class, and derive it from CActive
Re: Application Crashing after Receiving few UDP packets
[QUOTE=symbianyucca;906475]You should not derive the CActive in the same class that you do CAknView, instead do move thye active objects stuff into a new class, and derive it from CActive[/QUOTE]
So i need to create a new class and derive active object from it right??
All the supporting variables i have declared it in CSocket_UDPContainerView, will accessing those values in new class will create issues??
Also i tried porting the app in E6 phones i have.. it is sending and receiving packets, but Iam not able to access the IP address from Socket
TInetAddr addr;
TBuf<64> aIP;
addr = TInetAddr::Cast(iNameRecord.iAddr);
addr.SetPort(200);
addr.Output(aIP);
I tried accessing aIP it is returning '::1' - Same code is showing valid address during debug
Re: Application Crashing after Receiving few UDP packets
Thanks
Now the app is not crashing. It is working fine.
Now I'm trying to figure out why some junk value is coming as IP address when i call "addr.Output(aIP);"
Thanks everyone for the valuable help
Re: Application Crashing after Receiving few UDP packets
::1 is the compact form for localhost in IPv6. The same thing would be 127.0.0.1 with IPv4.
Re: Application Crashing after Receiving few UDP packets
[QUOTE=wizard_hu_;906583]::1 is the compact form for localhost in IPv6. The same thing would be 127.0.0.1 with IPv4.[/QUOTE]
But I'm able to send packets to my server using that socket and it is reaching there with a valid IP..
Is there any way to access the IP address by the device itself??
I don't understand why it behaving differently in Symbian 3.. Functionally everything is working fine.
Should i start a new post for this query??
Re: Application Crashing after Receiving few UDP packets
[QUOTE=Griffolyon-aka-Rick;906617]But I'm able to send packets to my server using that socket and it is reaching there with a valid IP.. [/QUOTE]
Yes, in this thread maybe you'll find a more detailed explanation of wizard_hu_ answer:
[url]http://www.developer.nokia.com/Community/Discussion/showthread.php?152882-Get-IP-address-of-WLAN-connection-other-application-is-using[/url]
[QUOTE=Griffolyon-aka-Rick;906617]Is there any way to access the IP address by the device itself?? [/QUOTE]
Yes, maybe one of these could help you, if you haven't found them yet:
[url]http://www.developer.nokia.com/Community/Wiki/Getting_Host%27s_IP_addresses_and_Interfaces[/url]
[url]http://www.developer.nokia.com/Community/Wiki/Getting_the_host_address_in_Symbian_C%2B%2B[/url]
regards,
pg
Re: Application Crashing after Receiving few UDP packets
[QUOTE=pavarang;906621]
Yes, maybe one of these could help you, if you haven't found them yet:
[url]http://www.developer.nokia.com/Community/Wiki/Getting_the_host_address_in_Symbian_C%2B%2B[/url]
regards,
pg[/QUOTE]
Thanks..
I got what i was looking for in this link..