I've programmed a little with amiga networking and wanted to receive UDP multicast messages. But without any success, on another computer i can see that responses to my query are send by other network members but they don't arrived at the amiga. Not in my program and they are even not observable by tcpdump on the amiga.
I tried to follow the following article: https://wiki.amigaos.net/wiki/Developin ... _Using_UDP
And that is the main setup part of my code, if needed and wanted i can attached a zip with the whole code (but its not nice)
Code: Select all
......
struct SocketIFace *ISocket = (struct SocketIFace*) open_interface("bsdsocket.library", 4, handleError);
if( ISocket != NULL ) {
int socket = ISocket->socket( AF_INET, SOCK_DGRAM,0 );
if( socket != -1 ) {
IDOS->Printf( "Socket created: %lu\n",socket );
/* Enable socket address reuse. */
int enabled = TRUE;
if( ISocket->setsockopt( socket, SOL_SOCKET, SO_REUSEADDR, &enabled, sizeof(enabled) ) == 0 ) {
IDOS->Printf( "Configured Socket address reuse\n" );
if( ISocket->setsockopt( socket, SOL_SOCKET, SO_REUSEPORT, &enabled, sizeof(enabled) ) == 0 ) {
IDOS->Printf( "Configured Socket port reuse\n" );
if( ISocket->setsockopt( socket, SOL_SOCKET, SO_OOBINLINE, &enabled, sizeof(enabled) ) == 0 ) {
IDOS->Printf( "Configured Socket for inline out-of-band data \n" );
struct sockaddr_in localAddress;
memset(&localAddress, 0, sizeof(struct sockaddr_in));
localAddress.sin_family = AF_INET;
localAddress.sin_port = htons( 5353 ); // mDNS port
localAddress.sin_addr.s_addr = htonl( INADDR_ANY ); // any source interface
IDOS->Printf( "Binding to local port %lu'...\n",localAddress.sin_port );
if( ISocket->bind( socket,(struct sockaddr*)&localAddress, sizeof(localAddress) ) == 0) {
long interfaceAddress = ISocket->inet_addr( (STRPTR)"172.16.0.117" );
struct in_addr hostAddress;
memcpy(&hostAddress, &interfaceAddress, sizeof(struct in_addr));
STRPTR multicastGroup = (STRPTR)"224.0.0.251";
long resolvedMulticastGroup = ISocket->inet_addr( multicastGroup ); // mDNS multicast adderss
struct in_addr multicastAddress;
memcpy(&multicastAddress, &resolvedMulticastGroup, sizeof(struct in_addr));
struct ip_mreq multicastMemberRequest;
multicastMemberRequest.imr_multiaddr = multicastAddress;
multicastMemberRequest.imr_interface = localAddress.sin_addr;
if( ISocket->setsockopt( socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &multicastMemberRequest, sizeof(multicastMemberRequest) ) == 0 ) {
IDOS->Printf( "Joined Multicast address\n" );
IDOS->Printf( "Start listening, stop with CTRL-C\n" );
fd_set readFds;
FD_ZERO( &readFds );
FD_SET( socket,&readFds );
fd_set writeFds;
FD_ZERO( &writeFds );
FD_SET( socket,&writeFds );
fd_set exceptFds;
FD_ZERO( &exceptFds );
FD_SET( socket,&exceptFds );
for( BOOL done = FALSE;!done; ) {
......
best regards