diff --git a/Source/igtlUDPServerSocket.cxx b/Source/igtlUDPServerSocket.cxx index 8953c63a..1082e473 100755 --- a/Source/igtlUDPServerSocket.cxx +++ b/Source/igtlUDPServerSocket.cxx @@ -85,7 +85,7 @@ int UDPServerSocket::AddGroup(const char* add, igtl_uint16 port, unsigned int gr } this->groups.push_back(GroupDest(add, port, groupID)); } - return 0; + return groupID; } //----------------------------------------------------------------------------- @@ -102,7 +102,7 @@ int UDPServerSocket::AddClient(const char* add, igtl_uint16 port, unsigned int c } } this->clients.push_back(ClientDest(add, port, clientID)); - return 0; + return clientID; } //----------------------------------------------------------------------------- @@ -142,7 +142,7 @@ int UDPServerSocket::CreateUDPServer() } //----------------------------------------------------------------------------- -int UDPServerSocket::DeleteClient(unsigned int groupID) +int UDPServerSocket::DeleteGroup(unsigned int groupID) { for(std::vector::size_type i = 0; this->groups.size(); i++) { @@ -155,6 +155,20 @@ int UDPServerSocket::DeleteClient(unsigned int groupID) return -1; } +//----------------------------------------------------------------------------- +int UDPServerSocket::DeleteClient(unsigned int clientID) +{ + for(std::vector::size_type i = 0; this->clients.size(); i++) + { + if (this->clients[i].clientID == clientID) + { + this->clients.erase(this->clients.begin()+i); + return 0; + } + } + return -1; +} + //----------------------------------------------------------------------------- void UDPServerSocket::PrintSelf(std::ostream& os) const { diff --git a/Source/igtlUDPServerSocket.h b/Source/igtlUDPServerSocket.h index 825c63f9..dcfe4803 100755 --- a/Source/igtlUDPServerSocket.h +++ b/Source/igtlUDPServerSocket.h @@ -83,20 +83,24 @@ class IGTLCommon_EXPORT UDPServerSocket : public GeneralSocket // Description: - // Add a client socket with given address at a given port and binds to it. + // Add a multicast socket with given address at a given port and binds to it. // Returns -1 on error. return clientID on success. - int AddGroup(const char* add, igtl_uint16 port, unsigned int clientID); + int AddGroup(const char* add, igtl_uint16 port, unsigned int groupID); // Description: // Add a client socket with given address at a given port and binds to it. // Returns -1 on error. return clientID on success. int AddClient(const char* add, igtl_uint16 port, unsigned int clientID); - // Description: - // Add a client socket with given address at a given port and binds to it. + // Delete a multicast socket with given ID. + // Returns -1 on error. 0 on success. + int DeleteGroup(unsigned int groupID); + + // Description: + // Delete a client socket with given ID. // Returns -1 on error. 0 on success. - int DeleteClient(unsigned int groupID); + int DeleteClient(unsigned int clientID); // Description: // Creates a UDP server socket at a given port and binds to it.