Click here to Skip to main content
15,898,581 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionKeeping an MDI file locked with CFile::shareExclusive Pin
bob169723-Aug-06 4:50
bob169723-Aug-06 4:50 
AnswerRe: Keeping an MDI file locked with CFile::shareExclusive Pin
Viorel.3-Aug-06 5:13
Viorel.3-Aug-06 5:13 
GeneralRe: Keeping an MDI file locked with CFile::shareExclusive Pin
bob169723-Aug-06 5:47
bob169723-Aug-06 5:47 
Questionneed good idea of print-preview Pin
includeh103-Aug-06 4:42
includeh103-Aug-06 4:42 
AnswerRe: need good idea of print-preview Pin
bob169723-Aug-06 4:59
bob169723-Aug-06 4:59 
GeneralRe: need good idea of print-preview Pin
includeh103-Aug-06 8:14
includeh103-Aug-06 8:14 
AnswerRe: need good idea of print-preview Pin
Hamid_RT4-Aug-06 7:02
Hamid_RT4-Aug-06 7:02 
QuestionWinsock - Multicasting with CCESocket [modified] Pin
king minger3-Aug-06 4:27
king minger3-Aug-06 4:27 
Hi I'm trying to extend Marco Zaratti's CCESocket class to cater for multicasting.

I'm just getting to grips with both winsock and multicasting but have come to a brick wall.

The basic pseudocode of Marco's class goes like this:

CCESocket::Create(SOCK_DGRAM)
   //some error checking}
   s = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)
   //some more error checking}
   //set some class member flags}

[my overridden function]
CMultiSock::Accept(localPort,localAddress)
   //call the base class function}
   CCESocket::Accept(localport)
        //error checking
        m_localAddress.sin_family = AF_INET;
	m_localAddress.sin_port = htons(localPort);
	m_localAddress.sin_addr.s_addr = htonl(INADDR_ANY);

	bind(s, (SOCKADDR*) &m_localAddress, sizeof(SOCKADDR_IN))
        //start a thread for a blocking receive containing:
              recvfrom(s,buf, bufSize, 0, (SOCKADDR*)&m_localAddress, &m_receiveAddrSz);
    return //from base accept

[my extra code to add multicast functionality in overridden Accept func]

<code>m_mReq.imr_multiaddr.s_addr = inet_addr("234.5.6.7");//224.0.23.167");
m_mReq.imr_interface.s_addr = INADDR_ANY;
m_localAddress.sin_addr.S_un.S_addr = inet_addr("234.5.6.7");
m_localAddress.sin_port = localport;
setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&m_mReq,sizeof(ip_mreq));
CreateEvent(NULL,FALSE,FALSE,L"Multicast-Event");

setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, (char *)&addr,sizeof(addr)); 
int TTL = 32 ;
nRet = setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL,(char*)&TTL, sizeof(TTL));
int loop = 1;
setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP,(char*)&loop, sizeof(loop));</code>


all returns are checked and this section has no problems

when I attempt to do a CCESocket::Send, the method goes through the accepting case, and sends to localaddress.

case SOCK_DGRAM:
if(m_udpReadyToSend)
{
while(len > 0)
{
if(m_socketState == ACCEPTING)
sentBytes = sendto(s, &buf[dataPtr], len, 0, (SOCKADDR*) &m_localAddress, sizeof(m_localAddress));
else 
sentBytes = sendto(s, &buf[dataPtr], len, 0, (SOCKADDR*) &m_remoteAddress, sizeof(m_remoteAddress));
.
.
.snip


except it fails with error WSAEINVAL.

if I change the address to match the multicast address it still fails.
does anyone know what could be the problem?

Alistair


-- modified at 10:28 Thursday 3rd August, 2006
NewsRe: Winsock - Multicasting with CCESocket [modified] Pin
king minger3-Aug-06 5:08
king minger3-Aug-06 5:08 
AnswerRe: Winsock - Multicasting with CCESocket Pin
king minger4-Aug-06 1:26
king minger4-Aug-06 1:26 
QuestionDeclaring Array Variable for a Class [modified] Pin
Andy Rama3-Aug-06 4:16
Andy Rama3-Aug-06 4:16 
AnswerRe: Declaring Array Variable for a Class Pin
David Crow3-Aug-06 4:22
David Crow3-Aug-06 4:22 
GeneralRe: Declaring Array Variable for a Class Pin
Andy Rama3-Aug-06 8:43
Andy Rama3-Aug-06 8:43 
QuestionRe: Declaring Array Variable for a Class Pin
David Crow4-Aug-06 2:32
David Crow4-Aug-06 2:32 
QuestionRe: Declaring Array Variable for a Class Pin
Andy Rama4-Aug-06 2:51
Andy Rama4-Aug-06 2:51 
AnswerRe: Declaring Array Variable for a Class Pin
David Crow4-Aug-06 2:59
David Crow4-Aug-06 2:59 
AnswerRe: Declaring Array Variable for a Class Pin
Zac Howland3-Aug-06 5:01
Zac Howland3-Aug-06 5:01 
GeneralRe: Declaring Array Variable for a Class Pin
Andy Rama3-Aug-06 19:31
Andy Rama3-Aug-06 19:31 
GeneralRe: Declaring Array Variable for a Class Pin
Zac Howland4-Aug-06 3:18
Zac Howland4-Aug-06 3:18 
GeneralRe: Declaring Array Variable for a Class Pin
Andy Rama4-Aug-06 8:01
Andy Rama4-Aug-06 8:01 
GeneralRe: Declaring Array Variable for a Class Pin
Zac Howland4-Aug-06 8:22
Zac Howland4-Aug-06 8:22 
Questionwhat does 0.1 inch mean? Pin
includeh103-Aug-06 4:07
includeh103-Aug-06 4:07 
AnswerRe: what does 0.1 inch mean? Pin
Chris Losinger3-Aug-06 4:09
professionalChris Losinger3-Aug-06 4:09 
JokeRe: what does 0.1 inch mean? Pin
ovidiucucu3-Aug-06 4:16
ovidiucucu3-Aug-06 4:16 
GeneralRe: what does 0.1 inch mean? Pin
includeh103-Aug-06 4:34
includeh103-Aug-06 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.