#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 |
|
|
|
|
|
Constructor. 00042 {}
|
|
|
Destructor. Does NOT delete the TCPSocket objects. 00047 {}
|
|
|
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 }
|
|
|
Deletes the socket objects. 00049 {
00050 for (SocketMap::iterator i=socketMap.begin(); i!=socketMap.end(); ++i)
00051 delete i->second;
00052 }
|
|
|
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 }
|
|
|
Returns the number of sockets stored. 00072 {return socketMap.size();}
|
|
|
|
1.4.1