multicast receive problem; setsockopt() gives WSAENOBUFS 
Author Message
 multicast receive problem; setsockopt() gives WSAENOBUFS

Hello

I am trying to make multicast receive work for CE.Net, but setsockopt()
allways produce error 10055 (WSAENOBUFS) when the code is run on target. The
code is taken from an MS helpfile and works for VS6.0 on host (win XP).

Any ideas?

Regards
William

Snippets from the code:

#define RECV_IP_ADDR      "234.5.6.7"
#define DEST_PORT         4567

  SOCKET Sock = INVALID_SOCKET;       // Datagram window socket

  struct ip_mreq mreq;                // Used in adding or dropping
multicasting addresses
  SOCKADDR_IN local_sin,    // Local socket's address
                               recv_sin;    // Holds the source address on
recvfrom function returns
  WSADATA WSAData;         // Contains details of the Winsock implementation

  // Initialize Winsock.
  WSAStartup (MAKEWORD(2,2), &WSAData);

  // Create a datagram socket, Sock.
  Sock = socket (AF_INET, SOCK_DGRAM, 0);

  // Fill out the local socket's address information.
  local_sin.sin_family = AF_INET;
  local_sin.sin_port = htons (DEST_PORT);
  local_sin.sin_addr.s_addr = htonl (INADDR_ANY);

  // Associate the local address with Sock.
  bind (Sock, (struct sockaddr FAR *) &local_sin, sizeof (local_sin));

  // Join the multicast group from which to receive datagrams.
  mreq.imr_multiaddr.s_addr = inet_addr (RECV_IP_ADDR);
  mreq.imr_interface.s_addr = INADDR_ANY;

  if (setsockopt (Sock,
                  IPPROTO_IP,
                  IP_ADD_MEMBERSHIP,
                  (char FAR *)&mreq,
                  sizeof (mreq)) == SOCKET_ERROR)
  {
    wsprintf (szError, TEXT("setsockopt failed! Error: %d"),
              WSAGetLastError ());
    MessageBox (NULL, szError, TEXT("Error"), MB_OK);
    closesocket (Sock);
    return FALSE;
  }



Mon, 16 May 2005 21:19:47 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem receiving multicast on CE .NET

2. setsockopt() problem?

3. setsockopt problem about TTL setting in winsock2

4. Problems with Multicast

5. Problem in Multicast Udp Receiver

6. Please HELP!! - WSAENOBUFS Error

7. CSocket::Send and WSAENOBUFS.

8. undefined reference to setsockopt, inet_addr, socket, htons

9. Set TTL value in broadcast (setsockopt)

10. 'setsockopt failed' error

11. is this SetSockOpt() syntax correct ?

12. setsockopt with Visual C++

 

 
Powered by phpBB® Forum Software