Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

According to the documentation the last argument to ISockPort_RecvFrom() is a pointer to the size of the address of the previous argument. It says " this size should be initialized to the size of the space that pAddr points to."

Which I am interpreting means I should use sizeof i.e.

 

	AEESockAddrStorage sa; 
	int nSockAddrSize = sizeof(AEESockAddrStorage);
	MEMSET(&sa, 0, sizeof(AEESockAddrStorage));

	int ret = ISockPort_RecvFrom(pMe->m_pIReceiveSockPort, pMe->m_caReceiveBuffer, 100, 0,  &sa, &nSockAddrSize); 

(The documentation also says sa the AEESockAddrStorage is filled in by ISockPort_ReceiveFrom(), so I am filling it with 0 prior to that to more easily see its changes in the IDE.)

 

However, despite what the documentation says about setting the size of the last argument, the example code from here https://developer.brewmp.com/resources/tech-guides/dns-multicast-qos-ssl-tcpip-technology-guide

does not do that, its code is:

 

int ret;
int nSockAddrSize;
AEESockAddrStorage sa;
CApp* pme = (CApp*)po;
// receive data from the server.
ret = ISOCKPORT_RecvFrom(pme->m_pISockPort, // ISockPort object
(pme->m_caReceiveBuffer + pme->m_uBytesReceived), // buffer for received (BUFFER_SIZE - pme->m_uBytesReceived) , // buffer length
0, // flags, not used
&sa, // pointer to the address &

Is this example code therefore incorrect?

 

I am getting a -1 from my call to ISockPort_RecvFrom(). Which upon calling ISockPort_GetLastError() returns AEE_EBADSTATE. What's wrong with my code? The previous code called before calling ISockPort_RecvFrom() is:

 

ISockPort* m_pIReceiveSockPort; // ISockPort pointer
char m_caReceiveBuffer[100]; //buffer to receive

...
ret = ISHELL_CreateInstance(m_pIShell, AEECLSID_SockPort, (void**)&(m_pIReceiveSockPort));

the last param &nSockAddrSize should containg the size of sa at the eim of call.Before calling ISockPort_RecvFrom, DGRAM Socket should be Opened & it should be bound to a local address.If you see in the sample code there is a Note in sending data to server.Note: The client is still not ready for receiving data, since it is not bounded. If you call ISockPort_SentTo it will aoutomatically bind the socket to a local address.Alternally, if you do not want to call ISockPort_SentTo(), you should bind the Socket explicitlly using ISockPort_Bind() before calling ISockPort_RecvFrom().

the last param &nSockAddrSize should containg the size of sa at the eim of call.Before calling ISockPort_RecvFrom, DGRAM Socket should be Opened & it should be bound to a local address.If you see in the sample code there is a Note in sending data to server.Note: The client is still not ready for receiving data, since it is not bounded. If you call ISockPort_SentTo it will aoutomatically bind the socket to a local address.Alternally, if you do not want to call ISockPort_SentTo(), you should bind the Socket explicitlly using ISockPort_Bind() before calling ISockPort_RecvFrom().