Hi Team,
Recently we moved out application from wx3.0 to wx3.1.
After merging wxWidgets 3.1 changes to our application, we are able to launch application, but after starting the application we observed that application is freezed for 2-3 minutes where it is trying to read socket data from the configuration server. Here we are observing wxSOCKET_IOERR.
Please find the code snippet for your reference.
Code: Select all
/*Structure describes the format of the after encoding "SocketMessage".
The byte array to be sent through the socket*/
typedef struct dataPacket
{
u8* pucData; /*byte array*/
u32 uiSize; /*Size of the byte array*/
}SockData;
E_RETURNCODES ConfigClient::getAll(void)
{
wxSocketClient* m_pGetSetSocket;
u8 *pucSockData = NULL;
SocketMessage stMsg;
SockData stSocketData;
wxIPV4address stAddr;
if(false == stAddr.Hostname(wxT("localhost")))
{
m_pLogFile->logMessage(__FILE__,__LINE__,wxT("configClient:: Not able to set the address for port %d"), iPort);
}
if( false == stAddr.Service(iPort))
{
m_pLogFile->logMessage(__FILE__,__LINE__,wxT("configClient:: Not able to set the service for port %d"), iPort);
}
if (NULL == m_pGetSetSocket)
{
/* Create the socket*/
m_pGetSetSocket = new wxSocketClient(wxSOCKET_BLOCK | wxSOCKET_WAITALL);
if (NULL == m_pGetSetSocket)
{
logMessage(__FILE__,__LINE__,wxT("configClient:: Not able to create a new client socket due to insufficient memory"));
return E_RET_ERROR;
}
m_pGetSetSocket->Connect(stAddr,true); // connection is successful
if(m_pGetSetSocket->IsConnected() == TRUE)
{
// returning TRUE
}
// we are writing GET_ALL_REQ to the server to read all the configuration parameters from the server.
m_pGetSetSocket->WriteMsg(stSocketData.pucData, stSocketData.uiSize);
// we checked socket error status & it is returning 0, hence socket write is passing successfully.
if(m_pGetSetSocket->Error() == true)
{
logMessage(__FILE__,__LINE__,wxT("configClient::getAll().Socket Error while sending CONFIG_MSG_GET_ALL_REQ request"));
return E_RET_ERROR;
}
delete []stSocketData.pucData;
// next we are trying to read data
{
pucSockData = new u8[MAX_LEN];
if (NULL != pucSockData)
{
// its failing in below function & it takes 2-3 minutes for reading data & later returns wxSOCKET_IOERR
m_pGetSetSocket->ReadMsg(pucSockData, MAX_LEN);
if(m_pGetSetSocket->Error() == true)
{
m_pLogFile->logMessage(__FILE__,__LINE__,wxT("configClient::getAll().Socket Error while reading"));
delete []pucSockData;
return E_RET_ERROR;
}
}
}
}
}
We observed that WriteMsg() is returning wxSOCKET_NOERROR, but ReadMsg() is taking 2-3 minutes time to execute & then returns wxSOCKET_IOERR.
Kindly tell us if we are doing anything wrong and let us know how to reach out the root cause for wxSOCKET_IOERR.
Please provide any debug pointers for the above case.
Regards,
Giri