1)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.
2.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.
3.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:
if(pMe->dnsresult.nResult > 0 && pMe->dnsresult.nResult
<= AEEDNSMAXADDRS) {
// DNS lookup success
// Process dnsresult.addrs
for(i = 0; i < pMe->dnsresult.nResult; i++) {
SPRINTF(szMsg,"Addr=: %x",pMe->dnsresult.addrs[i]);
DisplayOutput(pMe,i+4,szMsg);
}
} else {
// DNS Failure - error code is dnsresult.nResult
SPRINTF(szMsg, "DNS: error %d", pMe->dnsresult.nResult);
DisplayOutput(pMe, 2, szMsg);
}
4.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.
5.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.
6.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().
For Example:
void CommonWriteCB (void *pUser) {
char *psz = NULL;
int cbWrite;
… … …
SampleApp * pMe = (SampleApp*)pUser;
// pszData is the data to be written
psz = pszData;
cbWrite = STRLEN (pszData);
// Loop till all the bytes are written.
while (cbWrite > 0) {
rv = ISOCKET_Write(pMe->m_pISocket, (byte *)psz,
(uint16)cbWrite);
if (rv == AEE_NET_WOULDBLOCK) {
// No byte were written successfully. Register
// callback to try again later.
ISOCKET_Writeable(pMe->m_pISocket,
CommonWriteCB, (void *)pMe);
return;
} else if (rv == AEE_NET_ERROR) {
// Write Error.
ReleaseNetAndSocket(pMe);
return;
}
// In case of parital write, loop and write the rest
cbWrite -= rv;
psz += rv;
}
… … …
}
7.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.
8.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..
9.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);
}
10.How can we check the status of my sockets and PPP connection?
We can check on the status of the PPP connection (active, inactive, opening or closing) using INETMGR_NetStatus().
NetState netState = NET_INVALID_STATE;
AEENetStats netStats;
netState = INETMGR_NetStatus (pINetMgr, &netStats);
We can use INETMGR_OnEvent() to monitor both the status of the PPP connection and socket connections. Refer to NetMgrEvent enum in AEENet.h for a list of all network and socket events.
// Register to receive Network and Socket events
INETMGR_OnEvent(piNet, (PFNNETMGREVENT)CheckNetStatus,
(void*)pMe, TRUE);
//Callback invoked when Network/Socket event is received
static void CheckNetStatus(void* cxt,
NetMgrEvent evt, uint32 dwData) {
SampleApp *pMe = (SampleApp*)cxt;
if(evt == NE_PPP) {
// network event. dwData = NetState enum value
// refer NetState data structure in BREW API Reference doc
}
if(evt == NE_SO_CLOSING || evt == NE_SO_CLOSED) {
// socket event - closing or closed.
// DwData is pointer to socket
}
… …
return;
}
11.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.
12.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.
13.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.
For Example:
// Register to receive Network and Socket events
INETMGR_OnEvent(piNet, (PFNNETMGREVENT)CheckNetStatus,
(void*)pMe, TRUE);
//Callback invoked when Network/Socket event is received
static void CheckNetStatus(void* cxt, NetMgrEvent evt,
uint32 dwData)
{
SampleApp *pMe = (SampleApp*)cxt;
if(evt == NE_SO_CLOSING || evt == NE_SO_CLOSED) {
// flag set to false to indicate socket is disconnected
pMe->m_SocketConnected = FALSE;
ReleaseNetAndSocket(pMe);
}
if(evt == NE_SO_CONNECTED) {
// flag set to true to indicate socket is connected
pMe->m_SocketConnected = TRUE;
}
return;
}
14.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.
15.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
16.Can we have a listening TCP socket?
No. You use UDP, specifically, ISOCKET_Bind and ISOCKET_RecvFrom
17.Does BREW support blocking sockets?
No. BREW uses asynchronous sockets. You can use ISOCKET_Readable or ISOCKET_Writeable to be notified when it is safe to read/write.
No comments:
Post a Comment