Multicast.h
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. // Multicast.h: interface for the CMulticast class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_MULTICAST_H__F513328F_B1AE_4FBB_BA82_777E938EB58D__INCLUDED_)
  5. #define AFX_MULTICAST_H__F513328F_B1AE_4FBB_BA82_777E938EB58D__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "winsock2.h"
  10. #include "Ws2tcpip.h"
  11. #include "....公共类Buffer.h"
  12. #define   MAX_BUFFER_SIZE   50000
  13. class CMulticast  
  14. {
  15. public:
  16.          CMulticast();
  17. virtual ~CMulticast();
  18. //加入组播组
  19. bool     AddMemberShip( const char * ip , const int port );
  20.     //移出组播组
  21. void     DropMemberShip( void );
  22.     //是否连接
  23. bool     IsConnected( void ){ return this->m_sock != INVALID_SOCKET; }
  24. //发送组播数据
  25. bool     SendTo( CBuffer & buffer );
  26. //接收组播数据
  27. bool     ReceiveFrom( CBuffer & buffer );
  28. void     SetData( int user_data ){ this->user_data = user_data; }
  29. int      GetData( void ){ return this->user_data; }
  30. private:
  31. static   int InitWSAStatup;
  32. SOCKET   m_sock;
  33. struct   sockaddr_in addr;
  34. struct   ip_mreq command;
  35. int      user_data;
  36. char    recvBuffer[ MAX_BUFFER_SIZE ];
  37. };
  38. #endif // !defined(AFX_MULTICAST_H__F513328F_B1AE_4FBB_BA82_777E938EB58D__INCLUDED_)