diff options
author | fcolin | 2007-02-01 13:04:52 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 13:04:52 +0000 |
commit | 70ec417f72c6e451f11a3d553ba4db0714d0cb60 (patch) | |
tree | e64c66708f126b9090f02f3890f57261c05234f4 /Bus/Ivy | |
parent | dae120b6c2b10f8fc2e77bfc4d69d33820faf5bc (diff) | |
download | ivy-cplusplus-70ec417f72c6e451f11a3d553ba4db0714d0cb60.zip ivy-cplusplus-70ec417f72c6e451f11a3d553ba4db0714d0cb60.tar.gz ivy-cplusplus-70ec417f72c6e451f11a3d553ba4db0714d0cb60.tar.bz2 ivy-cplusplus-70ec417f72c6e451f11a3d553ba4db0714d0cb60.tar.xz |
Utilisateur : Fcolin Date : 29/06/00 Heure : 15:59 Archivé dans $/Ivy Commentaire: Version multicast (vss 3)
Diffstat (limited to 'Bus/Ivy')
-rw-r--r-- | Bus/Ivy/ThreadedSocket.cxx | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Bus/Ivy/ThreadedSocket.cxx b/Bus/Ivy/ThreadedSocket.cxx index 64df41e..1e20e8e 100644 --- a/Bus/Ivy/ThreadedSocket.cxx +++ b/Bus/Ivy/ThreadedSocket.cxx @@ -242,7 +242,7 @@ void CThreadedSocket::Send(const void* lpBuf, int nBufLen, int nFlags) void CThreadedSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, const char * lpszHostAddress, int nFlags)
{
SOCKADDR_IN sockAddr;
-
+
memset(&sockAddr,0,sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
@@ -266,11 +266,44 @@ void CThreadedSocket::SendTo(const void* lpBuf, int nBufLen, UINT nHostPort, con }
}
}
-
+
sockAddr.sin_port = htons((u_short)nHostPort);
SendTo(lpBuf, nBufLen, (SOCKADDR*)&sockAddr, sizeof(sockAddr), nFlags);
}
+void CThreadedSocket::AddMember( const char * lpszHostAddress )
+{
+ int multicast_ttl = 64; // region
+ struct ip_mreq imr;
+
+ TRACE("CThreadedSocket::AddMember adding %s\n", lpszHostAddress );
+ imr.imr_multiaddr.s_addr = INADDR_ANY;
+ imr.imr_interface.s_addr = INADDR_ANY;
+
+ if (lpszHostAddress )
+ {
+ imr.imr_multiaddr.s_addr = inet_addr(lpszHostAddress);
+ if (imr.imr_multiaddr.s_addr == INADDR_NONE)
+ {
+ LPHOSTENT lphost;
+ lphost = gethostbyname(lpszHostAddress);
+ if (lphost != NULL)
+ imr.imr_multiaddr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
+ else
+ {
+ WSASetLastError(WSAEINVAL);
+ throw( new CThreadedSocketException( "AddMenber" ));
+ return;
+ }
+ }
+ }
+ if ( IN_CLASSD( htonl(imr.imr_multiaddr.s_addr) ) )
+ {
+ SetSockOpt( IP_MULTICAST_TTL, &multicast_ttl, sizeof( multicast_ttl ), IPPROTO_IP );
+ SetSockOpt( IP_ADD_MEMBERSHIP, &imr, sizeof( imr ), IPPROTO_IP );
+ }
+
+}
void CThreadedSocket::AsyncSelect(long lEvent)
{
assert(m_hSocket != INVALID_SOCKET);
|