I have built a network application in OpenWRT v18.06.4 snapshot for MIPS architecture.
This version of OpenWRT uses musl toolchain (toolchain-mips_24kc_gcc-7.3.0_musl).
When tested, the application fails by flagging the following error:
-----------------------------------------------------------------------------------
SO_REUSEPORT defined
SOL_SOCKET = 65535, SO_REUSEADDR = 4, SO_REUSEPORT = 512, f = 516
ERROR: socket(s,(null-host):5000) setsockopt(SO_REUSEADDR) 99 Protocol not available
-----------------------------------------------------------------------------------
Following is the code snippet that fails and results in above run-time error:
------------------------------------------------------------------------------------------------
int r,f,v;
/* Mark as reuseable, avoid EADDRINUSE errors */
/* http://linux.die.net/man/7/socket */
/* http://linux.die.net/man/2/setsockopt */
f = SO_REUSEADDR;
#if defined(SO_REUSEPORT)
/* http://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t */
/* post Linux 3.9 */
f |= SO_REUSEPORT;
printf("SO_REUSEPORT defined \n");
#endif
v = 1;
printf("SOL_SOCKET = %d, SO_REUSEADDR = %d, SO_REUSEPORT = %d, f = %d \n", SOL_SOCKET, SO_REUSEADDR, SO_REUSEPORT, f);
r = setsockopt(pS->h, SOL_SOCKET, f, (const void *)(&v), sizeof(v));
if(r < 0)
{
_stream_socket_error(pS, "setsockopt(SO_REUSEADDR)", errno, NULL);
}
------------------------------------------------------------------------------------------------
Thanks,
Sanju