summaryrefslogtreecommitdiff
path: root/Ivy/ThreadedSocket.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy/ThreadedSocket.cxx')
-rw-r--r--Ivy/ThreadedSocket.cxx37
1 files changed, 35 insertions, 2 deletions
diff --git a/Ivy/ThreadedSocket.cxx b/Ivy/ThreadedSocket.cxx
index 64df41e..1e20e8e 100644
--- a/Ivy/ThreadedSocket.cxx
+++ b/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);