This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3120MOD: How to get client ip address before accepting its connection

Part Number: CC3120MOD

Hi,

How I can get ip address of client before I will accept its connection?

means how I can get destination ip address/client ip address for connection before I will call sl_Accept().

Can anyone support me on this!

I have tried by below code but in 'client_ip' I will get as 0 value always: -

// This tasks waits for incoming data forever
SL_SOCKET_FD_ZERO(&rxSet);
SL_SOCKET_FD_SET(connHandlr->Sd, &rxSet);

// Call select function with relevant parameters
status = sl_Select((connHandlr->Sd + 1), &rxSet, NULL, NULL, &timeVal);

if(status == TRUE)
{
  tmpCounter++;
}
else
{
  tmpCounter = 0;
}
/*will call sl_Task() to
get the events (Trigger/Timer) */
sl_Task(NULL);

/* If Trigger Event arrived (or if data is waiting but no event)
* Go to receive data */
if((g_triggerModeEventArrived == TRUE) || (tmpCounter >= 10))
{
  // Clear Event Indicatio
  g_triggerModeEventArrived = FALSE;
  tmpCounter = 0;
  client_ip = connHandlr->clientAdd.sin_addr.s_addr; // Update current client ip address
  returnVal = m_AcceptConnection(connHandlr);
}
return returnVal;

And when I will accept connection then I will get its ip address but I want it, before I will accept connection: -

//socket is marked, call accept
connHandlr->NewSd = sl_Accept(connHandlr->Sd, (SlSockAddr_t*)&Addr1, (SlSocklen_t*) &AddrSize);
client_ip = Addr1.sin_addr.s_addr; // Update current client ip address

 

Regards,

Mahendra Rana