#include <TCPSocketMap.h>
Public Member Functions | |
TCPSocketMap () | |
~TCPSocketMap () | |
TCPSocket * | findSocketFor (cMessage *msg) |
void | addSocket (TCPSocket *socket) |
TCPSocket * | removeSocket (TCPSocket *socket) |
unsigned int | size () |
void | deleteSockets () |
Protected Types | |
typedef std::map< int, TCPSocket * > | SocketMap |
Protected Attributes | |
SocketMap | socketMap |
typedef std::map<int,TCPSocket*> TCPSocketMap::SocketMap [protected] |
TCPSocketMap::~TCPSocketMap | ( | ) | [inline] |
void TCPSocketMap::addSocket | ( | TCPSocket * | socket | ) |
Registers the given socket. Should not be called multiple times for one socket object.
00035 { 00036 ASSERT(socketMap.find(socket->connectionId())==socketMap.end()); 00037 socketMap[socket->connectionId()] = socket; 00038 }
void TCPSocketMap::deleteSockets | ( | ) |
TCPSocket * TCPSocketMap::findSocketFor | ( | cMessage * | msg | ) |
Finds the socket (by connId) for the given message. The message must have arrived from TCP, and must contain a TCPCommand control info object. The method returns NULL if the socket was not found, and throws an error if the message doesn't contain a TCPCommand.
00024 { 00025 TCPCommand *ind = dynamic_cast<TCPCommand *>(msg->controlInfo()); 00026 if (!ind) 00027 opp_error("TCPSocketMap: findSocketFor(): no TCPCommand control info in message (not from TCP?)"); 00028 int connId = ind->connId(); 00029 SocketMap::iterator i = socketMap.find(connId); 00030 ASSERT(i==socketMap.end() || i->first==i->second->connectionId()); 00031 return (i==socketMap.end()) ? NULL : i->second; 00032 }
Removes the given socket from the data structure.
00041 { 00042 SocketMap::iterator i = socketMap.find(socket->connectionId()); 00043 if (i!=socketMap.end()) 00044 socketMap.erase(i); 00045 return socket; 00046 }
unsigned int TCPSocketMap::size | ( | ) | [inline] |
SocketMap TCPSocketMap::socketMap [protected] |