Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Source/igtlUDPServerSocket.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//-----------------------------------------------------------------------------
Expand All @@ -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;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -142,7 +142,7 @@ int UDPServerSocket::CreateUDPServer()
}

//-----------------------------------------------------------------------------
int UDPServerSocket::DeleteClient(unsigned int groupID)
int UDPServerSocket::DeleteGroup(unsigned int groupID)
{
for(std::vector<GroupDest>::size_type i = 0; this->groups.size(); i++)
{
Expand All @@ -155,6 +155,20 @@ int UDPServerSocket::DeleteClient(unsigned int groupID)
return -1;
}

//-----------------------------------------------------------------------------
int UDPServerSocket::DeleteClient(unsigned int clientID)
{
for(std::vector<ClientDest>::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
{
Expand Down
14 changes: 9 additions & 5 deletions Source/igtlUDPServerSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down