Socket programming: Using IP_ADD_MEMBERSHIP is not defined??? 
Author Message
 Socket programming: Using IP_ADD_MEMBERSHIP is not defined???

Hi.
I want to make a simple multicast program.
Here's example.

#include <winsock2.h>
...
setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&mreq,sizeof(mreq)
...

an error message is
error C2065: 'IP_ADD_MEMBERSHIP' : undeclared identifier

I don't know why did this happen.
I though that IP_ADD_MEMBERSHIP is already in the winsock2.h, but I coudn't
find it in winsock2.h.
Where is it?
What header file do I need to include?
Thank you.
Have a good weekend.




Wed, 26 Nov 2003 06:56:22 GMT  
 Socket programming: Using IP_ADD_MEMBERSHIP is not defined???

        It is defined in winsock.h ( also in ws2tcpip.h  )

Cheers
Check Abdoul
-----------------


Quote:
> Hi.
> I want to make a simple multicast program.
> Here's example.

> #include <winsock2.h>
> ...
> setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&mreq,sizeof(mreq)
> ...

> an error message is
> error C2065: 'IP_ADD_MEMBERSHIP' : undeclared identifier

> I don't know why did this happen.
> I though that IP_ADD_MEMBERSHIP is already in the winsock2.h, but I
coudn't
> find it in winsock2.h.
> Where is it?
> What header file do I need to include?
> Thank you.
> Have a good weekend.





Wed, 26 Nov 2003 07:19:47 GMT  
 Socket programming: Using IP_ADD_MEMBERSHIP is not defined???
...
#include <winsock2.h>
#include <ws2tcpip.h>
...
...
setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&mreq,sizeof(mreq)
...

error messages are
Linking...
multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

multi_test_client.obj : error LNK2001: unresolved external symbol

I already link ws2_32.lib with this program.
And also I can't include <winsock.h> with <winsock2.h>
But obviously, IP_ADD_MEMBERSHIP is defined in ws2tcpip.h.


Quote:

>         It is defined in winsock.h ( also in ws2tcpip.h  )

> Cheers
> Check Abdoul
> -----------------



> > Hi.
> > I want to make a simple multicast program.
> > Here's example.

> > #include <winsock2.h>
> > ...
> > setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&mreq,sizeof(mreq)
> > ...

> > an error message is
> > error C2065: 'IP_ADD_MEMBERSHIP' : undeclared identifier

> > I don't know why did this happen.
> > I though that IP_ADD_MEMBERSHIP is already in the winsock2.h, but I
> coudn't
> > find it in winsock2.h.
> > Where is it?
> > What header file do I need to include?
> > Thank you.
> > Have a good weekend.





Wed, 26 Nov 2003 10:41:10 GMT  
 Socket programming: Using IP_ADD_MEMBERSHIP is not defined???
Oops...
I'm sorry.
I made a mistake.
I didn't link ws2_32.lib here, because I have multi project with my vc...
so maybe ws2_32.lib only linked to the server part.
Thank you very much.
I solved this problem, thanks to you.


Quote:
> ...
> #include <winsock2.h>
> #include <ws2tcpip.h>
> ...
> ...
> setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&mreq,sizeof(mreq)
> ...

> error messages are
> Linking...
> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> multi_test_client.obj : error LNK2001: unresolved external symbol

> I already link ws2_32.lib with this program.
> And also I can't include <winsock.h> with <winsock2.h>
> But obviously, IP_ADD_MEMBERSHIP is defined in ws2tcpip.h.



> >         It is defined in winsock.h ( also in ws2tcpip.h  )

> > Cheers
> > Check Abdoul
> > -----------------



> > > Hi.
> > > I want to make a simple multicast program.
> > > Here's example.

> > > #include <winsock2.h>
> > > ...
> > > setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&mreq,sizeof(mreq)
> > > ...

> > > an error message is
> > > error C2065: 'IP_ADD_MEMBERSHIP' : undeclared identifier

> > > I don't know why did this happen.
> > > I though that IP_ADD_MEMBERSHIP is already in the winsock2.h, but I
> > coudn't
> > > find it in winsock2.h.
> > > Where is it?
> > > What header file do I need to include?
> > > Thank you.
> > > Have a good weekend.





Wed, 26 Nov 2003 10:44:58 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ending a blocing sockets call (am using MFC's CSocket class)

2. I am not quite understand the program asks for

3. I am not quite understand the program asks for

4. I am new to programming and am lost

5. Identifiers NOT to define in your programs (revised version)

6. Q:warning "defined but not used"

7. socket programming problem (network not reachable)

8. socket programming problem (network not reachable)

9. FTP and sockets (not using WinInet)?

10. Socket testing using loopback not reliable?

11. FTP and sockets (not using WinInet)?

12. flushing iptables using C socket program ?

 

 
Powered by phpBB® Forum Software