Essential Brew Interview Questions Part – 3
After Making A Voice Call Using Itapi_makevoicecall, Why Does My Application Seem To Be Restarted When I Respond ‘no’ To The “return To Application” Prompt?
Make sure that the parameter clsReturn (application to start when the call ends) in the call to ITAPI_MakeVoiceCall is 0 (zero). If you specify clsReturn as your app’s Class ID, then BREW tries to create another instance of your app, rather than resume your app.
What Guidelines Should Follow When Making A Voice Call Immediately After A Data Call?
After the last socket is released, BREW waits for the network linger time (default linger time is 30s) to expire before terminating the PPP connection. The actual tearing down of the PPP connection takes about 3s. Therefore, (linger time + 3 seconds) must elapse between releasing the last socket and invoking ITAPI_MakeVoiceCall(). You should introduce a (linger time + 3 seconds) timer
between releasing the last socket and making the voice call.
When Making A Voice Call Immediately After A Data Call, Why Do We See The Privacy Alert Again Instead Of “return To Application”?
Refer to above FAQ In addition to the more common causes, stack overrun can also lead to SWI Exceptions.
Note:
It is recommended that large buffers be allocated on the heap rather than on the stack as automatic variables.
When Will Brew Offer Http Support?
HTTP Support is available through the AEEWeb interface in version 1.1 of the BREW SDK and above. With earlier versions of the SDK, use the ISocket interface to connect to a server’s HTTP port, and send HTTP “get” and “post” requests.
Why Does Gethostbyname() Not Work On My Phone?
For INETMGR_GetHostByName() to function correctly, the phone’s Domain Name Server (DNS) settings must be properly configured. This is generally taken care of by the Service Provider, in which case the phone should be returned to the place of purchase, or an authorized service center so that its DNS settings can be properly configured.
Why Do We Get The Value Of 0.0.0.0 In Dnsresult.addrs When I Use Gethostbyname()?
This may be due to incorrect implementation of error handling in the GetHostByName() callback function. The error handling implementation in the GetHostByName() callback of the NetSocket example is incorrect. You can use the following sample implementation:
With No Tcp/ip Flush Command Available In Brew, How Can I Confirm That A Command Is Sent Right Away?
It is not possible to determine when a TCP/IP command is sent; BREW does not provide this capability.
What Is The Largest Packet Size Supported By Brew?
The maximum packet size is OEM dependant, and may vary from one manufacturer’s phone to another. BREW has no control over this limitation.
When Transmitting Large Files, Do We Have To Break The File Up Into Packets Before Sending, Or Does Brew Do This For Me?
You should simply send what you can, and ISOCKET_Write() will tell you how much data was actually sent. If there is data remaining to be sent, simply offset your data pointer by the amount indicated by your last call to ISOCKET_Write().
How Many Sockets Can Be Opened Simultaneously?
This limit is OEM specific, and will vary depending on the device that your applet is running on—it is not set by BREW.
Note:
Multiple TCP sockets are not supported on the Kyocera 3035. It allows one TCP socket and one UDP socket at a given time.
Are Network Callbacks Invoked In The Context Of The Main Thread, And If So How Is The Data Integrity Preserved In The Current Context?
All network callbacks occur within the same thread context, at some point in time after the caller returns control to the AEE event loop. If your application is busy doing something, callbacks will be queued, then invoked once your application returns control to the AEE event loop, ensuring data integrity..
When Reading From A Socket The Phone Reads Whatever It Can In One Go, While The Emulator Reads Large Packets In Chunks. Why?
This is a limitation of the phone.
Program should call ISOCKET_Readable() to be informed when more data can be read from the stream. The callback routine registered by ISOCKET_Readable() will be invoked whenever data becomes available—you can usually call ISOCKET_Read() at this point. Continue calling ISOCKET_Readable() for as long as your program expects more data.
rv = ISOCKET_Read(piSock, (byte *)szBuf, sizeof(szBuf));
if (rv == AEE_NET_WOULDBLOCK) {
// WOULDBLOCK => no more data available at the moment
// Register the callback to read the data later.
ISOCKET_Readable(piSock, CommonReadCB, (void*)pMe);
return;
}
else if (rv == AEE_NET_ERROR) {
// error reading from socket
ReleaseNetAndSocket (pMe);
}
else if (rv > 0) {
// rv bytes of data has been read from the socket into
// szBuf
// Read remaining data
ISOCKET_Readable(piSock, CommonReadCB, (void*)pMe);
}
else { // rv == 0
// There is no more data to be received.
// The peer has shut down the connection.
ReleaseNetAndSocket (pMe);
}
Is It Possible To Transfer Data Between Two Phones?
Peer to peer connections between two phones have been found to be unreliable, failing when the phones are on the same subnet. It is best therefore to use a proxy server, transferring data between the phones using the server as a go between.
Can A Brew-enabled Device Be Used As A Server?
In addition to the obvious memory and performance limitations, it is not possible to listen on a socket connection when a BREW application is running on a phone. These factors make implementing a server on BREW difficult at best.
Is There Any Way To Tell If A Socket Is Already Connected?
There are two ways to determine if a socket is connected. The easiest is to check the return value of ISOCKET_Connect(). When a socket is already connected, ISOCKET_Connect() will return EISCONN.
It is also possible to monitor the state of a socket connection by registering for the socket status change events NE_SO_CLOSING, and NE_SO_CLOSED with INETMGR_OnEvent(). Using this method, your application can avoid trying to connect an already connected socket.
For more information about network and socket events, including NE_SO_CLOSING and NE_SO_CLOSED, please refer to the following include file: AEENet.h
Why Does Isocket_release() Return One When We Are Expecting A Return Value Of Zero?
When an application calls ISOCKET_Release(), the internal state of the ISocket object changes to “closing,” and BREW begins waiting for the asynchronous “closed” event. Since the closed event is received in a callback, the reference count of the ISocket object is incremented to prevent it from being released before its internal state changes to closed.
Why Does Ishell_createinstance Return Eclassnotsupport When I Try And Create An Instance Of The Net Manager (aeeclsid_net)?
This is because of the permissions on the MIF file for your applet. Please open your MIF file in the MIF editor and check the checkbox for Network privileges, then save
Can We Have A Listening Tcp Socket?
No. You use UDP, specifically, ISOCKET_Bind and ISOCKET_RecvFrom
Does Brew Support Blocking Sockets?
BREW uses asynchronous sockets. You can use ISOCKET_Readable or ISOCKET_Writeable to be notified when it is safe to read/write.
What Image Formats Are Supported In Brew?
BREW supports any BMP file with a color depth up to that which is provided on the device it is running on. BREW does not yet support GIF and JPEG images. For now, you need to convert GIF and JPEG images into BMP images. PNG format and BREW Compressed Image (BCI) format will be supported in BREW SDK version 1.1.
In SDK versions prior to 1.1, the emulator is capable of emulating only 1, 4, and 8 bit color depth BMPs. In version 1.1, the emulator can also display 2 bit color depth BMPs
What Is The Transparent Color On Color And Monochrome Phones?
Magenta is the transparent color for color devices. White is the transparent color on monochrome and 4-level gray-scale devices.
How Can We Create A Scroll Bar If Menu Is Larger Than The Screen Size?
The screen rectangle in which the menu is to be drawn (specified by IMENUCTL_SetRect) must exceed the screen height by at least the height of a single menu item. Otherwise the menu item will be clipped and no scroll bar will appear.
How Cancwe Add Images To The Items In An Imenuctl?
We can use the IMENUCTL_AddItemEx method with CtlAddItem structure.
Can We Remove The Multitap Item From The Softkey Menu Associated With My Text Control?
Yes, We can remove it by following the steps outlined below:
Associate the soft key menu with your text control using ITEXTCTL_SetSoftKey().
Call IMENUCTL_DeleteAll() to delete the Multitap item.
Add items using IMENUCTL_AddItem().
Is It Possible To Get/manipulate The Palette Information Of The Device?
No. The palettes are hard-coded by the vendor and will vary from device to device.
Can We Modify The Display Buffers Directly?
No. There is no way for BREW to access these and the display data is stored as the vendor’s proprietary format.