I just found out about PGM (Pragmatic General Multicast) in windows sockets. I read up on msdn how to configure a send and receive socket but it's not working.
This is the code so far:
#pragma comment(lib,"Ws2_32.lib")
#include <stdio.h>
#include <iostream>
#include <ws2tcpip.h>
#include <Winsock2.h>
#include <wsrm.h>
int main( int argc, const char* argv[] )
{
DWORD dwRet = NO_ERROR;
WSADATA wsa_data;
if( WSAStartup( MAKEWORD( 2, 0 ), &wsa_data ) != 0 ) {
dwRet = GetLastError();
WSACleanup();
return dwRet;
}
SOCKET s;
SOCKADDR_IN salocal, sasession;
int dwSessionPort;
s = socket( AF_INET, SOCK_RDM, IPPROTO_RM );
if( s == INVALID_SOCKET )
{
dwRet = GetLastError();
WSACleanup();
return dwRet;
}
salocal.sin_family = AF_INET;
salocal.sin_port = htons (0); // Port is ignored here
salocal.sin_addr.s_addr = htonl (INADDR_ANY);
int iRet = bind (s, (SOCKADDR *)&salocal, sizeof(salocal));
if( iRet == SOCKET_ERROR )
{
dwRet = GetLastError();
WSACleanup();
return dwRet;
}
dwSessionPort = 0;
sasession.sin_family = AF_INET;
sasession.sin_port = htons (dwSessionPort);
sasession.sin_addr.s_addr = inet_addr ("234.5.6.7");
connect (s, (SOCKADDR *)&sasession, sizeof(sasession));
return dwRet;
}
I get error code 10044 (Socket type not supported) when i try to create the socket. How do I enable the use of PGM?
I'm currently working on Windows 7 with MSMQ installed.
EDIT This is the msdn site I read up on.
Found the solution, the MSMQ wasn´t properly installed. In order for it to include all features (Multicast Support) all the subfolders had to be explicitly checked as shown in the picture below.