#include <SocketManager.h>
Collaboration diagram for vpr::sim::SocketManager:

Public Methods | |
| SocketManager (void) | |
| void | setActive (void) |
| vpr::ReturnStatus | connect (vpr::SocketImplSIM *localSock, const vpr::InetAddrSIM &remoteName, NetworkGraph::VertexListPtr &path, vpr::Interval timeout) |
| If the socket is of type SOCK_STREAM, then this call attempts to make a connection to another socket. More... | |
| vpr::ReturnStatus | bind (vpr::SocketImplSIM *handle) |
| Bind ties the given adddress to the given socket. More... | |
| vpr::ReturnStatus | unbind (vpr::SocketImplSIM *handle) |
| Unbinds the given socket from its registered address. More... | |
| vpr::ReturnStatus | listen (vpr::SocketStreamImplSIM *handle, const int backlog=5) |
| Sets a socket s to listen for connections. More... | |
| void | findRoute (vpr::SocketImplSIM *src_sock, vpr::SocketImplSIM *dest_sock) |
| void | sendMessage (vpr::sim::MessagePtr msg) |
| Puts the given message on its way to its destination. More... | |
| void | sendMessageTo (vpr::sim::MessagePtr msg, const vpr::SocketImplSIM *src_sock, const vpr::InetAddrSIM &dest_addr) |
| Defines the path from the source socket to the destination address for the given message. More... | |
| bool | isListening (const vpr::InetAddrSIM &address) |
| Is there someone listening on the address? More... | |
Protected Types | |
| typedef std::map< vpr::InetAddr, vpr::SocketStreamImplSIM * > | listener_map_t |
| typedef std::map< vpr::Uint32, vpr::sim::NetworkNodePtr > | node_map_t |
Protected Methods | |
| vpr::ReturnStatus | assignToNode (vpr::SocketImplSIM *handle) |
| Assign the given socket to a node on the actual network This is based on the following address scheme for assignment. More... | |
| vpr::ReturnStatus | unassignFromNode (vpr::SocketImplSIM *handle) |
| Unassigns the socket from the node that it is bound to This is basically the opposite of assignToNode (and unbind if you will). More... | |
| vpr::ReturnStatus | ensureNetworkNodeIsRegistered (const vpr::Uint32 &ipAddr) |
| Make sure that the local data structures know about the node at the given address. More... | |
| SocketManager (const SocketManager &o) | |
| Get the ip address value for the "localhost" node that we are using. More... | |
| void | operator= (const SocketManager &o) |
Protected Attributes | |
| bool | mActive |
| listener_map_t | mListenerList |
| This is a list of sockets that have gone into a listening state Used to track which sockets are currently in a listening state XXX: Could move this into the actually socket as a socket state instead. More... | |
| vpr::Mutex | mListenerListMutex |
| node_map_t | mNetworkNodes |
| The nodes in the managed network. More... | |
| vpr::Mutex | mNetworkNodesMutex |
This is used by Plexus sim sockets, and in the overall sim socket scheme, this sits at the operating system level. This roughly corresponds to the data link or transport layer.
It provides a way to bind address and send messages.
Definition at line 87 of file SocketManager.h.
|
|
Definition at line 246 of file SocketManager.h. |
|
|
Definition at line 247 of file SocketManager.h. |
|
|
Definition at line 90 of file SocketManager.h.
00090 : mActive(false) 00091 { 00092 /* Do nothing. */ ; 00093 } |
|
|
Get the ip address value for the "localhost" node that we are using.
Definition at line 237 of file SocketManager.h.
00237 {;}
|
|
|
Definition at line 95 of file SocketManager.h. Referenced by vpr::sim::Controller::constructNetwork.
00096 {
00097 mActive = true;
00098 }
|
|
||||||||||||||||||||
|
If the socket is of type SOCK_STREAM, then this call attempts to make a connection to another socket. The other socket is specified by name, which is an address in the communications space of the socket. If the socket is of type SOCK_DGRAM, then this call specifies the peer with which the socket is to be associated; this address is that to which datagrams are to be sent, and the only address from which datagrams are to be received. Each communications space interprets the name parameter in its own way. Generally, stream sockets may successfully connect only once; datagram sockets may use connect multiple times to change their association. Datagram sockets may dissolve the association by connecting to an invalid address, such as a zero-filled address. Definition at line 83 of file SocketManager.cpp. References vpr::MutexPosix::acquire, vpr::sim::Controller::addConnectionEvent, vpr::SocketStreamImplSIM::addConnector, vpr::SocketImplSIM::completeConnection, vpr::ReturnStatus::Fail, vpr::ReturnStatus::failure, vpr::sim::Controller::getClock, vpr::sim::Clock::getCurrentTime, vpr::SocketImplSIM::getNetworkNode, vpr::sim::Controller::instance, vpr::SocketImplSIM::isBound, isListening, mActive, mListenerList, mListenerListMutex, vpr::SocketImplSIM::mLocalAddr, vpr::MutexPosix::release, vpr::ReturnStatus::setCode, vprASSERT, vprDBG_ALL, vprDBG_CRITICAL_LVL, vprDBG_STATE_LVL, vprDEBUG, and vprDEBUG_FLUSH. Referenced by vpr::SocketImplSIM::connect.
00087 {
00088 vprASSERT(mActive && "Socket manager not activated yet");
00089 vprASSERT(localSock->isBound() && "Precondition is that socket is bound");
00090 vprASSERT(localSock->mLocalAddr != vpr::InetAddr::AnyAddr && "Must be bound to an address");
00091
00092 vpr::ReturnStatus status;
00093
00094 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00095 <<"connect( "<<remoteName<<" )\n"<<vprDEBUG_FLUSH;
00096
00097 vpr::SocketStreamImplSIM* local_stream_socket;
00098 local_stream_socket = dynamic_cast<vpr::SocketStreamImplSIM*>(localSock);
00099
00100 // If we have a vpr::SocketStreamImplSIM* object, we perform a real
00101 // simulated connection.
00102 if ( local_stream_socket != NULL )
00103 {
00104 if ( isListening( remoteName ) ) // If remote side is accepting connections
00105 {
00106 vpr::SocketImplSIM* remote_sock;
00107
00108 mListenerListMutex.acquire();
00109 {
00110 vprASSERT(mListenerList.find(remoteName) != mListenerList.end());
00111 remote_sock = (*mListenerList.find(remoteName)).second;
00112 }
00113 mListenerListMutex.release();
00114
00115 vpr::SocketStreamImplSIM* remote_stream_socket
00116 = dynamic_cast<vpr::SocketStreamImplSIM*>(remote_sock);
00117 vprASSERT(NULL != remote_stream_socket && "We should have a stream socket, but don't");
00118
00119 // Queue us up in the listening socket's connection queue.
00120 status = remote_stream_socket->addConnector(localSock);
00121 vprASSERT(!status.failure() && "Failed to add connector");
00122
00123 vpr::sim::Controller* controller = vpr::sim::Controller::instance();
00124 controller->addConnectionEvent(controller->getClock().getCurrentTime(), remote_sock);
00125 }
00126 else
00127 {
00128 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
00129 << "vpr::sim::SocketManager: Cannot connect, no one listening on "
00130 << remoteName << std::endl << vprDEBUG_FLUSH;
00131
00132 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << "--------- Listening list ---------\n" << vprDEBUG_FLUSH;
00133 for(listener_map_t::iterator i=mListenerList.begin();
00134 i != mListenerList.end(); ++i)
00135 { vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << (*i).second->getLocalAddr() << std::endl << vprDEBUG_FLUSH; }
00136 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << "---- [End] Listening list ---------\n" << vprDEBUG_FLUSH;
00137
00138 vprASSERT(false && "Tried to connect to a non-listening node");
00139 status.setCode(vpr::ReturnStatus::Fail);
00140 }
00141 }
00142 // We are dealing with datagram sockets.
00143 else
00144 {
00145 vpr::SocketImplSIM* remote_sock;
00146 vpr::SocketDatagramImplSIM* remote_dgram_socket;
00147
00148 mListenerListMutex.acquire();
00149 {
00150 vprASSERT(mListenerList.find(remoteName) != mListenerList.end());
00151 remote_sock = (*mListenerList.find(remoteName)).second;
00152 }
00153 mListenerListMutex.release();
00154
00155 remote_dgram_socket = dynamic_cast<vpr::SocketDatagramImplSIM*>(remote_sock);
00156
00157 // Ensure that we really did get a datagram socket. Basically, the
00158 // only reason dgram_socket exists is for this conditional.
00159 vprASSERT( remote_dgram_socket != NULL );
00160
00161 // We have to cast away the const-ness so that we can add the
00162 // connector information.
00163 localSock->completeConnection( remote_sock );
00164 // XXX: Don't tell the other side that it is connected to us
00165 //remote_dgram_socket->completeConnection(localSock);
00166
00167 // Now find the shortest path between u and v.
00168 const NetworkGraph::net_vertex_t& u = localSock->getNetworkNode();
00169 const NetworkGraph::net_vertex_t& v = remote_dgram_socket->getNetworkNode();
00170 path = vpr::sim::Controller::instance()->getNetworkGraph().getShortestPath(u, v);
00171 }
00172
00173 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL) << "DONE: connect()\n"
00174 << vprDEBUG_FLUSH;
00175 return status;
00176 }
|
|
|
Bind ties the given adddress to the given socket. In reality, this registers the given socket object with the simulator and makes it possible to look up the socket by its address. Assign the socket to the network somwhere Case localAddr = InetAddr::Any ==> 0x7F000001 with random port Case localAddr = Have IP and port=0 (ie. Give me a random port. I don't care) Case localAddr = Have IP and port != 0 (bind me to that exact one)
Definition at line 184 of file SocketManager.cpp. References assignToNode, vpr::SocketImplSIM::isBound, vpr::SocketImplSIM::isOpen, vprASSERT, vprDBG_ALL, vprDBG_STATE_LVL, vprDEBUG_BEGIN, vprDEBUG_END, and vprDEBUG_FLUSH. Referenced by vpr::SocketImplSIM::bind.
00185 {
00186 vprASSERT(handle->isOpen() && !handle->isBound() && "Against preconditions to have a handle not open or already bound");
00187 vprDEBUG_BEGIN(vprDBG_ALL, vprDBG_STATE_LVL) << "bind(" << handle << ")\n" << vprDEBUG_FLUSH;
00188
00189 vpr::ReturnStatus ret_stat = assignToNode(handle);
00190
00191 vprDEBUG_END(vprDBG_ALL, vprDBG_STATE_LVL) << "bind complete\n" << vprDEBUG_FLUSH;
00192
00193 return ret_stat;
00194 }
|
|
|
Unbinds the given socket from its registered address. Once the socket is unbound, it should close. For sockets that are not bound, no action is taken.
Definition at line 196 of file SocketManager.cpp. References vpr::SocketImplSIM::getLocalAddr, vpr::SocketImplSIM::isBound, unassignFromNode, vprASSERT, vprDBG_ALL, vprDBG_STATE_LVL, vprDEBUG, and vprDEBUG_FLUSH.
00197 {
00198 vpr::ReturnStatus status;
00199
00200 vprASSERT( handle->isBound() && "Can't unbind and unbound handle");
00201
00202 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00203 << "Unbinding handle (" << handle << " --> "
00204 << handle->getLocalAddr() << ")\n" << vprDEBUG_FLUSH;
00205
00206 // -- Unassign from node
00207 status = unassignFromNode( handle );
00208
00209 return status;
00210 }
|
|
||||||||||||
|
Sets a socket s to listen for connections.
Definition at line 214 of file SocketManager.cpp. References vpr::MutexPosix::acquire, vpr::SocketImplSIM::getLocalAddr, vpr::SocketImplSIM::getType, vpr::SocketImplSIM::isBound, isListening, mListenerList, mListenerListMutex, vpr::MutexPosix::release, vprASSERT, vprDBG_ALL, vprDBG_STATE_LVL, vprDEBUG, and vprDEBUG_FLUSH.
00216 {
00217 vpr::ReturnStatus status;
00218
00219 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL) <<"SocketManager::listen: Added listner: " << handle->getLocalAddr() << std::endl
00220 << vprDEBUG_FLUSH;
00221 vprASSERT( handle->isBound() && "Can't listen on unbound socket");
00222 vprASSERT( handle->getType() == vpr::SocketTypes::STREAM && "Trying to listen with not stream socket");
00223
00224 // enter self into list for accepting connections.
00225 mListenerListMutex.acquire();
00226 {
00227 mListenerList[handle->getLocalAddr()] = handle;
00228 }
00229 mListenerListMutex.release();
00230
00231 vprASSERT( isListening(handle->getLocalAddr()) && "Didn't add listener" );
00232
00233 return status;
00234 }
|
|
||||||||||||
|
Definition at line 237 of file SocketManager.cpp. References vpr::SocketImplSIM::getNetworkNode, vpr::sim::NetworkGraph::getShortestPath, vpr::sim::Controller::instance, mActive, vpr::sim::NetworkGraph::reversePath, vpr::SocketImplSIM::setPathToPeer, and vprASSERT. Referenced by vpr::SocketStreamImplSIM::accept.
00239 {
00240 vprASSERT(mActive && "Socket manager not activated!");
00241
00242 const NetworkGraph::net_vertex_t& u = src_sock->getNetworkNode();
00243 const NetworkGraph::net_vertex_t& v = dest_sock->getNetworkNode();
00244 NetworkGraph::VertexListPtr path;
00245 vpr::sim::NetworkGraph& net_graph =
00246 vpr::sim::Controller::instance()->getNetworkGraph();
00247
00248 // Now find the shortest path between u and v.
00249 path = net_graph.getShortestPath(u, v);
00250 src_sock->setPathToPeer(path);
00251 dest_sock->setPathToPeer(net_graph.reversePath(path));
00252 }
|
|
|
Puts the given message on its way to its destination. This call should be used for "reliable" messages or messages that know where they are going. Definition at line 254 of file SocketManager.cpp. References vpr::sim::Controller::addLocalhostDeliveryEvent, vpr::sim::Controller::addMessageEvent, vpr::sim::Controller::getClock, vpr::sim::Clock::getCurrentTime, vpr::sim::NetworkGraph::getEdge, vpr::sim::NetworkGraph::getLineProperty, vpr::sim::Controller::getNetworkGraph, vpr::sim::Controller::instance, vpr::sim::NetworkGraph::isSource, mActive, vpr::Interval::now, vprASSERT, vprDBG_ALL, vprDBG_HVERB_LVL, vprDBG_STATE_LVL, vprDBG_VERB_LVL, vprDEBUG, and vprDEBUG_FLUSH. Referenced by sendMessageTo.
00255 {
00256 // There is no point in doing anything if we do not have a controller
00257 // for the simulation.
00258 vprASSERT(mActive && "Socket manager not activated yet");
00259
00260 vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL)
00261 << "SocketManager::sendMessage(): Sending message from "
00262 << msg->getSourceSocket()->getLocalAddr() << " to "
00263 << msg->getDestinationSocket()->getLocalAddr() << "\n"
00264 << vprDEBUG_FLUSH;
00265
00266 NetworkGraph::net_vertex_t first_hop(msg->getNextHop());
00267
00268 bool end_of_path;
00269 msg->incNextHop(end_of_path);
00270
00271 vpr::sim::Controller* controller = vpr::sim::Controller::instance();
00272
00273 if ( ! end_of_path )
00274 {
00275 NetworkGraph::net_vertex_t second_hop(msg->getNextHop());
00276 NetworkGraph::net_edge_t first_edge;
00277 bool found;
00278 vpr::sim::NetworkGraph& net_graph = controller->getNetworkGraph();
00279
00280 boost::tie(first_edge, found) = net_graph.getEdge(first_hop, second_hop);
00281
00282 if ( found )
00283 {
00284 NetworkLine::LineDirection dir;
00285
00286 NetworkLine& first_edge_prop = net_graph.getLineProperty(first_edge);
00287
00288 // Determine the direction for the message on this line.
00289 dir = net_graph.isSource(first_hop, first_edge) ? NetworkLine::FORWARD : NetworkLine::REVERSE;
00290 first_edge_prop.calculateMessageEventTimes(msg, vpr::Interval::now(),
00291 dir);
00292
00293 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00294 << "SocketManager::sendMessage(): Starting message ["
00295 << msg->getSourceSocket()->getLocalAddr() << " ==> "
00296 << msg->getDestinationSocket()->getLocalAddr() << "] on wire "
00297 << first_edge_prop.getNetworkAddressString() << ": ("
00298 << msg->whenStartOnWire().getBaseVal() << ", "
00299 << msg->whenFullyOnWire().getBaseVal() << ", "
00300 << msg->whenArrivesFully().getBaseVal() << ")\n"
00301 << vprDEBUG_FLUSH;
00302
00303 first_edge_prop.addMessage(msg, dir);
00304 controller->addMessageEvent(msg->whenArrivesFully(), first_edge,
00305 dir);
00306 }
00307 }
00308 // This is a loopback, so we can just deliver the message without going
00309 // through the network.
00310 else
00311 {
00312 vprASSERT(msg->getSourceSocket()->getLocalAddr().getAddressValue() == msg->getDestinationSocket()->getLocalAddr().getAddressValue()
00313 && "Could not get second node in message's path");
00314 vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)
00315 << "SocketManager::sendMessage(): Loopback--delivering to "
00316 << msg->getDestinationSocket()->getLocalAddr() << "("
00317 << msg->getDestinationSocket() << ") immediately\n"
00318 << vprDEBUG_FLUSH;
00319 msg->getDestinationSocket()->addArrivedMessage(msg);
00320 controller->addLocalhostDeliveryEvent(controller->getClock().getCurrentTime(),
00321 msg->getDestinationSocket());
00322 }
00323 }
|
|
||||||||||||||||
|
Defines the path from the source socket to the destination address for the given message. This call should be used for "unreliable" messages only. For example, the given destination address may be unreachable, and thus the message will not be delivered. Definition at line 325 of file SocketManager.cpp. References vpr::InetAddrSIM::getAddressValue, vpr::SocketImplSIM::getNetworkNode, vpr::sim::NetworkGraph::getNodeProperty, vpr::sim::NetworkGraph::getNodeWithAddr, vpr::InetAddrSIM::getPort, vpr::sim::NetworkGraph::getShortestPath, vpr::SocketImplSIM::getType, vpr::sim::Controller::instance, vpr::SocketImplSIM::isBound, vpr::sim::NetworkNodePtr, sendMessage, vpr::ReturnStatus::success, and vprASSERT. Referenced by vpr::SocketDatagramImplSIM::sendto.
00328 {
00329 vprASSERT(src_sock->getType() == vpr::SocketTypes::DATAGRAM && "Only datagram sockets may use sendMessageTo()");
00330
00331 vpr::ReturnStatus status;
00332 NetworkGraph::net_vertex_t dest_node;
00333 vpr::sim::NetworkGraph& net_graph =
00334 vpr::sim::Controller::instance()->getNetworkGraph();
00335
00336 status = net_graph.getNodeWithAddr(dest_addr.getAddressValue(), dest_node);
00337
00338 if ( status.success() )
00339 {
00340 NetworkNodePtr dest_node_prop;
00341
00342 dest_node_prop = net_graph.getNodeProperty(dest_node);
00343
00344 if ( dest_node_prop->hasSocket(dest_addr.getPort(), vpr::SocketTypes::DATAGRAM) )
00345 {
00346 vpr::SocketImplSIM* peer;
00347 NetworkGraph::VertexListPtr path;
00348
00349 peer = dest_node_prop->getSocket( dest_addr.getPort(), vpr::SocketTypes::DATAGRAM);
00350
00351 vprASSERT(src_sock->isBound() && "Trying to send from socket not bound.");
00352 path = net_graph.getShortestPath(src_sock->getNetworkNode(), dest_node);
00353 msg->setPath(path, src_sock, peer);
00354
00355 // At this point, the message is ready to go, so we can send it in
00356 // the same manner as a "reliable" message.
00357 sendMessage(msg);
00358 }
00359 }
00360 }
|
|
|
Is there someone listening on the address?
Definition at line 364 of file SocketManager.cpp. References vpr::MutexPosix::acquire, mListenerList, mListenerListMutex, and vpr::MutexPosix::release. Referenced by connect, and listen.
00365 {
00366 bool status;
00367
00368 mListenerListMutex.acquire();
00369 {
00370 status = (mListenerList.find( address) != mListenerList.end());
00371 }
00372 mListenerListMutex.release();
00373
00374 return status;
00375 }
|
|
|
Assign the given socket to a node on the actual network This is based on the following address scheme for assignment. Assign the socket to the network somwhere Case localAddr = InetAddr::Any ==> 0x7F000001 with random port Case localAddr = Have IP and port=0 (ie. Give me a random port. I don't care) Case localAddr = Have IP and port != 0 (bind me to that exact one) Definition at line 383 of file SocketManager.cpp. References ensureNetworkNodeIsRegistered, vpr::InetAddrSIM::getAddressValue, vpr::SocketImplSIM::getLocalAddr, vpr::InetAddrSIM::getPort, vpr::SocketImplSIM::getType, vpr::sim::LocalHostIpAddrValue, mNetworkNodes, vpr::sim::NetworkNodePtr, vpr::InetAddrSIM::setAddress, vpr::SocketImplSIM::setLocalAddr, vpr::SocketImplSIM::setNetworkNode, vpr::InetAddrSIM::setPort, vpr::ReturnStatus::success, vprASSERT, vprDBG_ALL, vprDBG_STATE_LVL, vprDEBUG, and vprDEBUG_FLUSH. Referenced by bind.
00384 {
00385 vpr::ReturnStatus status;
00386 NetworkGraph net_graph = Controller::instance()->getNetworkGraph();
00387
00388 // --- Get the local address setup correctly --- //
00389 vpr::InetAddrSIM local_addr;
00390 local_addr = handle->getLocalAddr();
00391
00392 // If any addr, then set it to local host
00393 // Case localAddr = InetAddr::Any ==> "localhost" with random port
00394 if(local_addr == vpr::InetAddr::AnyAddr )
00395 {
00396 local_addr.setAddress(LocalHostIpAddrValue, 0);
00397 }
00398
00399 // Make sure that we know about the node of the given address
00400 ensureNetworkNodeIsRegistered(local_addr.getAddressValue() );
00401 vprASSERT( mNetworkNodes.find(local_addr.getAddressValue()) != mNetworkNodes.end());
00402
00403 // --- Bind the socket to an actual node in the graph -- //
00404 // - Get the node
00405 // - Register this socket with that node
00406 NetworkNodePtr net_node = mNetworkNodes[local_addr.getAddressValue()];
00407
00408 // - Deal with port assignment issues
00409 // Case localAddr = Have IP and port=0 (ie. Give me a random port. I don't care)
00410 // Case localAddr = Have IP and port != 0 (bind me to that exact one)
00411 if(local_addr.getPort() == 0)
00412 {
00413 vpr::Uint32 port_num;
00414 if(handle->getType() == vpr::SocketTypes::STREAM)
00415 { port_num = net_node->getUnassignedTcpPortNumber(); }
00416 else
00417 { port_num = net_node->getUnassignedUdpPortNumber(); }
00418 local_addr.setPort(port_num);
00419 }
00420
00421 // Set the final local address and add the socket to the node
00422 handle->setLocalAddr(local_addr);
00423 net_node->addSocket( handle );
00424
00425 // Store the network node vertex in the socket for fast access
00426 NetworkGraph::net_vertex_t node_vertex;
00427 status = net_graph.getNodeWithAddr(local_addr.getAddressValue(), node_vertex);
00428 vprASSERT(status.success());
00429 handle->setNetworkNode( node_vertex );
00430
00431 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00432 << "SocketManager::assignToNode(): Assigned node: local_addr:" << local_addr
00433 << " type: " << ((handle->getType()==vpr::SocketTypes::STREAM) ? "STREAM" : "DATAGRAM")
00434 << " --> node: " << net_node->getIpAddressString() << std::endl << vprDEBUG_FLUSH;
00435
00436 return status;
00437 }
|
|
|
Unassigns the socket from the node that it is bound to This is basically the opposite of assignToNode (and unbind if you will).
Definition at line 439 of file SocketManager.cpp. References vpr::InetAddrSIM::getAddressValue, vpr::SocketImplSIM::getLocalAddr, mNetworkNodes, vpr::sim::NetworkNodePtr, vpr::ReturnStatus::success, and vprASSERT. Referenced by unbind.
00440 {
00441 vpr::ReturnStatus status;
00442 vpr::InetAddrSIM local_addr = handle->getLocalAddr();
00443 vprASSERT( mNetworkNodes.find(local_addr.getAddressValue()) != mNetworkNodes.end());
00444
00445 // Get the network node
00446 NetworkNodePtr net_node = mNetworkNodes[local_addr.getAddressValue()];
00447
00448 // Remove the socket from the node
00449 status = net_node->removeSocket( handle );
00450 vprASSERT(status.success());
00451
00452 return status;
00453 }
|
|
|
Make sure that the local data structures know about the node at the given address.
Definition at line 455 of file SocketManager.cpp. References mNetworkNodes, vpr::sim::NetworkNodePtr, vpr::ReturnStatus::Succeed, vpr::ReturnStatus::success, and vprASSERT. Referenced by assignToNode.
00456 {
00457 vpr::ReturnStatus ret_stat(vpr::ReturnStatus::Succeed);
00458
00459 if( mNetworkNodes.find(ipAddr) == mNetworkNodes.end()) // If not registered yet
00460 {
00461 NetworkGraph::net_vertex_t node_vertex;
00462 NetworkGraph net_graph = Controller::instance()->getNetworkGraph();
00463
00464 ret_stat = net_graph.getNodeWithAddr(ipAddr, node_vertex);
00465 vprASSERT(ret_stat.success() && "Specified IP address does not actually exist in the sim net graph.");
00466
00467 NetworkNodePtr node_prop = net_graph.getNodeProperty(node_vertex);
00468 vprASSERT(node_prop.get() != NULL);
00469
00470 mNetworkNodes.insert( std::pair<node_map_t::key_type, node_map_t::data_type>(ipAddr, node_prop) );
00471 }
00472
00473 return ret_stat;
00474 }
|
|
|
Definition at line 238 of file SocketManager.h.
00238 {;}
|
|
|
Definition at line 240 of file SocketManager.h. Referenced by connect, findRoute, and sendMessage. |
|
|
This is a list of sockets that have gone into a listening state Used to track which sockets are currently in a listening state XXX: Could move this into the actually socket as a socket state instead.
Definition at line 254 of file SocketManager.h. Referenced by connect, isListening, and listen. |
|
|
Definition at line 255 of file SocketManager.h. Referenced by connect, isListening, and listen. |
|
|
The nodes in the managed network.
Definition at line 261 of file SocketManager.h. Referenced by assignToNode, ensureNetworkNodeIsRegistered, and unassignFromNode. |
|
|
Definition at line 262 of file SocketManager.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002