#include <SocketImplSIM.h>
Inheritance diagram for vpr::SocketImplSIM:


Public Methods | |
| virtual | ~SocketImplSIM () |
| Destructor. More... | |
| const std::string & | getName () const |
| Gets the "name" of this socket. More... | |
| vpr::ReturnStatus | open () |
| Opens the socket. More... | |
| bool | isOpen () const |
| Gets the open state of this socket. More... | |
| bool | isBound () const |
| vpr::ReturnStatus | close () |
| Closes the socket. More... | |
| vpr::IOSysSIM::Handle | getHandle () const |
| Gets the handle to this socket. More... | |
| vpr::ReturnStatus | setReuseAddr (bool adr) |
| vpr::ReturnStatus | bind () |
| Binds this socket to the address in the host address member variable. More... | |
| vpr::ReturnStatus | setBlocking (bool blocking) |
| Reconfigures the socket so that it is in blocking or non-blocking mode. More... | |
| bool | isBlocking () const |
| Gets the current blocking state for the socket. More... | |
| vpr::ReturnStatus | connect (vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Connects the socket on the client side to the server side. More... | |
| vpr::ReturnStatus | completeConnection (SocketImplSIM *connectedPeer) |
| Completes a previously started connection to a given peer. More... | |
| bool | isConnected () const |
| Gets the status of a possibly connected socket. More... | |
| const vpr::SocketTypes::Type & | getType () const |
| Gets the type of this socket (e.g., vpr::SocketTypes::STREAM). More... | |
| const vpr::InetAddr & | getLocalAddr () const |
| vpr::ReturnStatus | setLocalAddr (const vpr::InetAddr &addr) |
| const vpr::InetAddr & | getRemoteAddr () const |
| vpr::ReturnStatus | setRemoteAddr (const vpr::InetAddr &addr) |
| virtual vpr::Uint32 | availableBytes () const |
| Returns the number of bytes currently available for reading. More... | |
| vpr::ReturnStatus | read_i (void *buffer, const vpr::Uint32 length, vpr::Uint32 &data_read, vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Implementation of the read template method. More... | |
| vpr::ReturnStatus | read_i (boost::shared_ptr< std::vector< vpr::Uint8 > > &msgData, vpr::Uint32 &data_read, vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Exactly like read_i except takes MessageDataPtr directly for zero copy networking Updates msgData to point at the new message data. More... | |
| vpr::ReturnStatus | readn_i (void *buffer, const vpr::Uint32 length, vpr::Uint32 &data_read, vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Implementation of the readn template method. More... | |
| vpr::ReturnStatus | readn_i (boost::shared_ptr< std::vector< vpr::Uint8 > > &msgData, vpr::Uint32 &data_read, vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Exactly like read_i except takes MessageDataPtr directly for zero copy networking. More... | |
| vpr::ReturnStatus | write_i (const void *buffer, const vpr::Uint32 length, vpr::Uint32 &data_written, vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Implementation of the write template method. More... | |
| vpr::ReturnStatus | write_i (boost::shared_ptr< std::vector< vpr::Uint8 > > msgData, vpr::Uint32 &data_written, vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Exactly like write_i except takes MessageDataPtr directly for zero copy networking Starts passing a shared copy of msgData across the network. More... | |
| vpr::ReturnStatus | getOption (const vpr::SocketOptions::Types option, struct vpr::SocketOptions::Data &data) |
| Retrieves the value for the given option as set on the socket. More... | |
| vpr::ReturnStatus | setOption (const vpr::SocketOptions::Types option, const struct vpr::SocketOptions::Data &data) |
| Sets a value for the given option on the socket using the given data block. More... | |
| virtual vpr::ReturnStatus | isReadReady () const=0 |
| Tests if this socket can read without blocking. More... | |
| virtual vpr::ReturnStatus | isWriteReady () const=0 |
| Tests if this socket can write without blocking. More... | |
| vpr::ReturnStatus | inExceptState () |
| Tests if this socket is in an exceptional state. More... | |
| void | addArrivedMessage (vpr::sim::MessagePtr msg) |
| void | setPathToPeer (vpr::sim::NetworkGraph::VertexListPtr path) |
| void | setNetworkNode (const vpr::sim::NetworkGraph::net_vertex_t &node) |
| vpr::sim::NetworkGraph::net_vertex_t | getNetworkNode () const |
Protected Types | |
| typedef std::deque< vpr::sim::MessagePtr > | arrival_queue_t |
Protected Methods | |
| void | disconnect () |
| SocketImplSIM (const vpr::SocketTypes::Type sock_type) | |
| This just initializes member variables to reasonable defaults. More... | |
| SocketImplSIM (const vpr::InetAddr &local_addr, const vpr::InetAddr &remote_addr, const vpr::SocketTypes::Type sock_type) | |
| Standard constructor. More... | |
| void | setConnectState (vpr::SocketImplSIM *peer) |
| Sets this socket's connected state using the given pointer value. More... | |
Protected Attributes | |
| std::string | mName |
| bool | mOpen |
| bool | mBound |
| bool | mBlocking |
| vpr::InetAddr | mLocalAddr |
| The local site's address structure. More... | |
| vpr::InetAddr | mRemoteAddr |
| The remote site's address structure. More... | |
| const vpr::SocketTypes::Type | mType |
| STREAM, DATAGRAM, or RAW. More... | |
| bool | mReuseAddr |
| reuse this address? More... | |
| arrival_queue_t | mArrivedQueue |
| FIFO of arrived msgs. More... | |
| vpr::Mutex | mArrivedQueueMutex |
| Mutex for the arrived message queue. More... | |
| vpr::sim::NetworkGraph::net_vertex_t | mNetworkNode |
| vpr::sim::NetworkGraph::VertexListPtr | mPathToPeer |
Friends | |
| class | vpr::sim::SocketManager |
This can be used in the vpr::Socket_t bridge template.
Definition at line 84 of file SocketImplSIM.h.
|
|
Definition at line 567 of file SocketImplSIM.h. |
|
|
Destructor. This will close the socket. Definition at line 59 of file SocketImplSIM.cpp. References close, vprDBG_ALL, vprDBG_HEX_LVL, vprDBG_STATE_LVL, vprDEBUG, and vprDEBUG_FLUSH.
00060 {
00061 vpr::DebugOutputGuard dbg_output(vprDBG_ALL, vprDBG_STATE_LVL,
00062 std::string("SocketImplSIM destructor: Deleting socket\n"),
00063 std::string("Done deleting socket.\n"));
00064
00065 if ( mOpen )
00066 {
00067 close();
00068 }
00069
00070 vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL)
00071 << "Deleting memory at address " << std::hex << this << std::dec
00072 << std::endl << vprDEBUG_FLUSH;
00073 }
|
|
|
This just initializes member variables to reasonable defaults.
Definition at line 517 of file SocketImplSIM.cpp. Referenced by vpr::SocketDatagramImplSIM::SocketDatagramImplSIM.
00518 : mOpen(false) 00519 , mBound(false) 00520 , mBlocking(false) 00521 , mType(sock_type) 00522 , mReuseAddr(false) 00523 , mConnected(false) 00524 , mPeer(NULL) 00525 { 00526 /* Do nothing. */ ; 00527 } |
|
||||||||||||||||
|
Standard constructor. This takes two vpr::InetAddr objects, a local address and a remote address.
Definition at line 529 of file SocketImplSIM.cpp.
00532 : mOpen(false) 00533 , mBound(false) 00534 , mBlocking(false) 00535 , mLocalAddr(local_addr) 00536 , mRemoteAddr(remote_addr) 00537 , mType(sock_type) 00538 , mConnected(false) 00539 , mPeer(NULL) 00540 { 00541 /* Do nothing. */ ; 00542 } |
|
|
Gets the "name" of this socket. It is typically the address of the peer host.
Definition at line 102 of file SocketImplSIM.h.
00103 {
00104 return mName;
00105 }
|
|
|
Opens the socket. This creates a new socket using the domain and type options set through member variables.
Definition at line 120 of file SocketImplSIM.h.
00121 {
00122 mOpen = true;
00123
00124 return vpr::ReturnStatus();
00125 }
|
|
|
Gets the open state of this socket.
Definition at line 137 of file SocketImplSIM.h. Referenced by vpr::sim::SocketManager::bind, vpr::SocketStreamImplSIM::isReadReady, and vpr::SocketStreamImplSIM::isWriteReady.
00138 {
00139 return mOpen;
00140 }
|
|
|
Definition at line 142 of file SocketImplSIM.h. Referenced by vpr::sim::SocketManager::bind, vpr::sim::SocketManager::connect, vpr::sim::SocketManager::listen, vpr::sim::SocketManager::sendMessageTo, and vpr::sim::SocketManager::unbind.
00143 {
00144 return mBound;
00145 }
|
|
|
Closes the socket.
Definition at line 75 of file SocketImplSIM.cpp. References disconnect, vpr::sim::Controller::instance, isConnected, mBound, mLocalAddr, mOpen, mPathToPeer, vprASSERT, vprDBG_ALL, vprDBG_STATE_LVL, vprDEBUG, and vprDEBUG_FLUSH. Referenced by ~SocketImplSIM.
00076 {
00077 vpr::DebugOutputGuard dbg_output(vprDBG_ALL, vprDBG_STATE_LVL,
00078 std::string("SocketImplSIM::close(): Closing socket ...\n"),
00079 std::string("Done closing socket.\n"));
00080 vpr::ReturnStatus status;
00081
00082 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00083 << "SocketImplSIM::close: " << mLocalAddr << std::endl << vprDEBUG_FLUSH;
00084
00085 if ( isConnected() )
00086 {
00087 vprASSERT(mPeer != NULL && "I am connected to a NULL peer");
00088
00089 // We tell our peer that we are disconnecting. This is a little
00090 // different than how real sockets work, but since we communicate
00091 // directly with our peer, this is a reasonable thing to do.
00092 mPeer->disconnect();
00093 disconnect();
00094 vpr::sim::Controller::instance()->flushPath(this, mPathToPeer);
00095 }
00096
00097 vprASSERT(mPeer == NULL && "I should not have a peer at this point");
00098
00099 if ( mBound )
00100 {
00101 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00102 << "SocketImplSIM::close: Unbinding: " << mLocalAddr << std::endl
00103 << vprDEBUG_FLUSH;
00104 // Release the node to which we were bound.
00105 status = vpr::sim::Controller::instance()->getSocketManager().unbind(this);
00106 mBound = false;
00107 }
00108
00109 mOpen = false;
00110
00111 return status;
00112 }
|
|
|
Gets the handle to this socket.
Definition at line 163 of file SocketImplSIM.h. References vpr::IOSysSIM::Handle.
00164 {
00165 return this;
00166 }
|
|
|
Definition at line 169 of file SocketImplSIM.h.
00170 {
00171 mReuseAddr = adr;
00172 return vpr::ReturnStatus();
00173 }
|
|
|
Binds this socket to the address in the host address member variable.
Definition at line 114 of file SocketImplSIM.cpp. References vpr::sim::SocketManager::bind, vpr::sim::Controller::instance, mBound, and vpr::ReturnStatus::success. Referenced by connect, and vpr::SocketDatagramImplSIM::sendto.
00115 {
00116 vpr::ReturnStatus status;
00117 vpr::sim::SocketManager& sock_mgr =
00118 vpr::sim::Controller::instance()->getSocketManager();
00119
00120 status = sock_mgr.bind(this);
00121 mBound = status.success();
00122
00123 return status;
00124 }
|
|
|
Reconfigures the socket so that it is in blocking or non-blocking mode.
Definition at line 197 of file SocketImplSIM.h.
00198 {
00199 mBlocking = blocking;
00200 return vpr::ReturnStatus(); // success
00201 }
|
|
|
Gets the current blocking state for the socket.
Definition at line 209 of file SocketImplSIM.h.
00210 {
00211 return mBlocking;
00212 }
|
|
|
Connects the socket on the client side to the server side. For a datagram socket, this makes the address given to the constructor the default destination for all packets. For a stream socket, this has the effect of establishing a connection with the destination.
Definition at line 126 of file SocketImplSIM.cpp. References bind, vpr::sim::SocketManager::connect, vpr::sim::Controller::instance, mBound, mOpen, mPathToPeer, mRemoteAddr, and vprASSERT.
00127 {
00128 vpr::ReturnStatus status;
00129 vprASSERT(mOpen && "An unopened socket cannot connect");
00130 vpr::sim::SocketManager& sock_mgr =
00131 vpr::sim::Controller::instance()->getSocketManager();
00132
00133 // If not bound, then bind us
00134 if (!mBound)
00135 {
00136 bind();
00137 }
00138
00139 vprASSERT(mBound && "We must be bound first");
00140
00141 status = sock_mgr.connect(this, mRemoteAddr, mPathToPeer, timeout);
00142 // NOTE: We are not connected until the other side says so
00143
00144 return status;
00145 }
|
|
|
Completes a previously started connection to a given peer. NOTE: UDP sockets can use this function as well. It lets them set a remote sockets peer and connection status. Definition at line 150 of file SocketImplSIM.cpp. References mRemoteAddr, setConnectState, and vpr::ReturnStatus::Succeed. Referenced by vpr::sim::SocketManager::connect.
00151 {
00152 setConnectState(connectedPeer);
00153 mRemoteAddr = connectedPeer->getLocalAddr();
00154
00155 return vpr::ReturnStatus::Succeed;
00156 }
|
|
|
Gets the status of a possibly connected socket.
Definition at line 255 of file SocketImplSIM.h. Referenced by close, vpr::SocketStreamImplSIM::isReadReady, and vpr::SocketStreamImplSIM::isWriteReady.
00256 {
00257 return mConnected;
00258 }
|
|
|
Gets the type of this socket (e.g., vpr::SocketTypes::STREAM).
Definition at line 269 of file SocketImplSIM.h. Referenced by vpr::sim::NetworkNode::addSocket, vpr::sim::SocketManager::assignToNode, vpr::sim::SocketManager::listen, vpr::sim::NetworkNode::removeSocket, and vpr::sim::SocketManager::sendMessageTo.
00270 {
00271 return mType;
00272 }
|
|
|
Definition at line 274 of file SocketImplSIM.h. Referenced by vpr::SocketStreamImplSIM::addConnector, vpr::sim::NetworkNode::addSocket, vpr::sim::SocketManager::assignToNode, vpr::sim::SocketManager::listen, vpr::sim::NetworkNode::removeSocket, vpr::sim::SocketManager::unassignFromNode, and vpr::sim::SocketManager::unbind.
00275 {
00276 return mLocalAddr;
00277 }
|
|
|
Definition at line 158 of file SocketImplSIM.cpp. References vpr::ReturnStatus::Fail, mLocalAddr, vpr::ReturnStatus::setCode, vprASSERT, vprDBG_ALL, vprDBG_HVERB_LVL, vprDEBUG, and vprDEBUG_FLUSH. Referenced by vpr::sim::SocketManager::assignToNode.
00159 {
00160 vpr::ReturnStatus status;
00161
00162 if ( mBound )
00163 {
00164 vprASSERT(false && "Can't change address of a bound socket");
00165 status.setCode(vpr::ReturnStatus::Fail);
00166 }
00167 else
00168 {
00169 vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL)
00170 << "SocketImplSIM::setLocalAddr(): Changing local address from "
00171 << mLocalAddr << " to " << addr << std::endl << vprDEBUG_FLUSH;
00172 mLocalAddr = addr;
00173 }
00174
00175 return status;
00176 }
|
|
|
Definition at line 281 of file SocketImplSIM.h.
00282 {
00283 return mRemoteAddr;
00284 }
|
|
|
Definition at line 178 of file SocketImplSIM.cpp. References vpr::ReturnStatus::Fail, mRemoteAddr, vpr::ReturnStatus::setCode, vprDBG_ALL, vprDBG_HVERB_LVL, vprDEBUG, and vprDEBUG_FLUSH.
00179 {
00180 vpr::ReturnStatus status;
00181
00182 // If we are connected, we cannot change our remote address.
00183 if ( mConnected )
00184 {
00185 status.setCode(vpr::ReturnStatus::Fail);
00186 }
00187 else
00188 {
00189 vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL)
00190 << "SocketImplSIM::setLocalAddr(): Changing remote address from "
00191 << mRemoteAddr << " to " << addr << std::endl << vprDEBUG_FLUSH;
00192 mRemoteAddr = addr;
00193 }
00194
00195 return status;
00196 }
|
|
|
Returns the number of bytes currently available for reading.
|
|
||||||||||||||||||||
|
Implementation of the read template method. This reads at most the specified number of bytes from the socket into the given buffer.
Definition at line 213 of file SocketImplSIM.cpp. References vpr::MutexPosix::acquire, mArrivedQueue, mArrivedQueueMutex, mOpen, vpr::MutexPosix::release, vprASSERT, and vpr::ReturnStatus::WouldBlock.
00217 {
00218 vpr:: ReturnStatus status;
00219 vprASSERT(mOpen && "Cannot read on an unopened socket");
00220
00221 // This is a rather long critical sectino, but we need to be sure that the
00222 // arrvied queue stays in a consistent state while we are working.
00223 mArrivedQueueMutex.acquire();
00224 {
00225 if ( ! mArrivedQueue.empty() )
00226 {
00227 vpr::sim::MessagePtr message;
00228 size_t copy_len, msg_size;
00229
00230 // Remove the message from the arrival queue.
00231 message = mArrivedQueue.front();
00232
00233 msg_size = message->getSize();
00234
00235 // Use the smaller of length and msg_size for the actual amount of
00236 // data to copy.
00237 copy_len = (length > msg_size) ? msg_size : length;
00238
00239 // Complete the read operation.
00240 memcpy(buffer, message->getBody(), copy_len);
00241 data_read = copy_len;
00242
00243 // If there was no resizing performed on the message (the resize value
00244 // is 0), then we have read the entire message into our buffer.
00245 if ( message->resize(copy_len) == 0 )
00246 {
00247 mArrivedQueue.pop_front();
00248 }
00249 }
00250 // Nothing is in the queue, so we tell the caller that the operation is
00251 // in progress.
00252 else
00253 {
00254 status.setCode(vpr::ReturnStatus::WouldBlock);
00255 data_read = 0;
00256 }
00257 }
00258 mArrivedQueueMutex.release();
00259
00260 return status;
00261 }
|
|
||||||||||||||||
|
Exactly like read_i except takes MessageDataPtr directly for zero copy networking Updates msgData to point at the new message data.
|
|
||||||||||||||||||||
|
Implementation of the readn template method. This reads exactly the specified number of bytes from the socket into the given buffer.
Definition at line 362 of file SocketImplSIM.h. References vpr::Interval::NoTimeout.
00365 {
00366 return read_i(buffer, length, data_read, timeout);
00367 }
|
|
||||||||||||||||
|
Exactly like read_i except takes MessageDataPtr directly for zero copy networking. Updates msgData to point at the new message data. Definition at line 373 of file SocketImplSIM.h. References vpr::Interval::NoTimeout.
00376 {
00377 return read_i(msgData, data_read, timeout);
00378 }
|
|
||||||||||||||||||||
|
Implementation of the write template method. This writes the buffer to the socket.
Definition at line 298 of file SocketImplSIM.cpp. References vpr::ReturnStatus::Fail, vpr::sim::Controller::instance, mBound, mOpen, mPathToPeer, vpr::ReturnStatus::setCode, vprASSERT, vprDBG_ALL, vprDBG_HEX_LVL, vprDEBUG, vprDEBUG_CONT, vprDEBUG_FLUSH, and vprDEBUG_NEXT.
00302 {
00303 vpr::ReturnStatus status;
00304 vprASSERT(mBound && "We must be bound first");
00305 vprASSERT(mOpen && "We must be open first");
00306
00307 if ( mPeer == NULL )
00308 {
00309 vprASSERT(false && "Trying to write to NULL peer"); // XXX: This may not be a good way to do this
00310 status.setCode(vpr::ReturnStatus::Fail);
00311 data_written = 0;
00312 }
00313 else
00314 {
00315 data_written = length;
00316
00317 #ifdef VPR_DEBUG
00318 vpr::Uint32 remainder;
00319 const char* msg_ptr = (const char*) buffer;
00320 remainder = length % 4;
00321
00322 vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL)
00323 << "SocketImplSIM::write_i(): Message (" << length
00324 << " bytes in 4-byte hex blocks):" << vprDEBUG_FLUSH;
00325
00326 for ( vpr::Uint32 i = 0; i < length; i += 4 )
00327 {
00328 if ( i % 16 == 0 )
00329 {
00330 vprDEBUG_NEXT(vprDBG_ALL, vprDBG_HEX_LVL)
00331 << "\n" << std::hex << std::setfill('0') << std::setw(8)
00332 << *((vpr::Uint32*) (&msg_ptr[i])) << " " << vprDEBUG_FLUSH;
00333 }
00334 else
00335 {
00336 vprDEBUG_CONT(vprDBG_ALL, vprDBG_HEX_LVL)
00337 << std::hex << std::setfill('0') << std::setw(8)
00338 << *((vpr::Uint32*) (&msg_ptr[i])) << " " << vprDEBUG_FLUSH;
00339 }
00340 }
00341
00342 for ( vpr::Uint32 i = 0; i < remainder; i++ )
00343 {
00344 vprDEBUG_CONT(vprDBG_ALL, vprDBG_HEX_LVL) << "00" << vprDEBUG_FLUSH;
00345 }
00346
00347 vprDEBUG_NEXT(vprDBG_ALL, vprDBG_HEX_LVL)
00348 << "\n---------------------------\n" << std::dec << vprDEBUG_FLUSH;
00349 #endif
00350
00351 vprASSERT(!mPathToPeer->empty() && "Path not set");
00352 vpr::sim::MessagePtr msg(new vpr::sim::Message(buffer, length));
00353 msg->setPath(mPathToPeer, this, mPeer);
00354 vpr::sim::Controller::instance()->getSocketManager().sendMessage(msg);
00355 }
00356
00357 return status;
00358 }
|
|
||||||||||||||||
|
Exactly like write_i except takes MessageDataPtr directly for zero copy networking Starts passing a shared copy of msgData across the network.
|
|
||||||||||||
|
Retrieves the value for the given option as set on the socket.
Definition at line 389 of file SocketImplSIM.cpp. References vpr::ReturnStatus::Fail, mReuseAddr, vpr::SocketOptions::Data::recv_buffer_size, vpr::SocketOptions::Data::reuse_addr, vpr::SocketOptions::Data::send_buffer_size, vpr::ReturnStatus::setCode, vpr::SOCK_MAX_BUFFER_SIZE, and vpr::SocketOptions::Data::type_of_service.
00391 {
00392 vpr::ReturnStatus status;
00393
00394 switch ( option )
00395 {
00396 // Socket-level options.
00397 case vpr::SocketOptions::Linger:
00398 status.setCode(vpr::ReturnStatus::Fail);
00399 break;
00400 case vpr::SocketOptions::ReuseAddr:
00401 data.reuse_addr = mReuseAddr;
00402 break;
00403 case vpr::SocketOptions::KeepAlive:
00404 status.setCode(vpr::ReturnStatus::Fail);
00405 break;
00406 case vpr::SocketOptions::RecvBufferSize:
00407 data.recv_buffer_size = SOCK_MAX_BUFFER_SIZE;
00408 break;
00409 case vpr::SocketOptions::SendBufferSize:
00410 data.send_buffer_size = SOCK_MAX_BUFFER_SIZE;
00411 break;
00412
00413 // IP-level options.
00414 case vpr::SocketOptions::IpTimeToLive:
00415 status.setCode(vpr::ReturnStatus::Fail);
00416 break;
00417 case vpr::SocketOptions::IpTypeOfService:
00418 data.type_of_service = vpr::SocketOptions::LowDelay;
00419 break;
00420 case vpr::SocketOptions::AddMember:
00421 status.setCode(vpr::ReturnStatus::Fail);
00422 break;
00423 case vpr::SocketOptions::DropMember:
00424 status.setCode(vpr::ReturnStatus::Fail);
00425 break;
00426 case vpr::SocketOptions::McastInterface:
00427 status.setCode(vpr::ReturnStatus::Fail);
00428 break;
00429 case vpr::SocketOptions::McastTimeToLive:
00430 status.setCode(vpr::ReturnStatus::Fail);
00431 break;
00432 case vpr::SocketOptions::McastLoopback:
00433 status.setCode(vpr::ReturnStatus::Fail);
00434 break;
00435
00436 // TCP-level options.
00437 case vpr::SocketOptions::NoDelay:
00438 status.setCode(vpr::ReturnStatus::Fail);
00439 break;
00440 case vpr::SocketOptions::MaxSegment:
00441 status.setCode(vpr::ReturnStatus::Fail);
00442 break;
00443 }
00444
00445 return status;
00446 }
|
|
||||||||||||
|
Sets a value for the given option on the socket using the given data block.
Definition at line 448 of file SocketImplSIM.cpp. References vpr::ReturnStatus::Fail, mReuseAddr, vpr::SocketOptions::Data::reuse_addr, and vpr::ReturnStatus::setCode.
00450 {
00451 vpr::ReturnStatus status;
00452
00453 switch ( option )
00454 {
00455 // Socket-level options.
00456 case vpr::SocketOptions::Linger:
00457 status.setCode(vpr::ReturnStatus::Fail);
00458 break;
00459 case vpr::SocketOptions::ReuseAddr:
00460 mReuseAddr = data.reuse_addr;
00461 break;
00462 case vpr::SocketOptions::KeepAlive:
00463 status.setCode(vpr::ReturnStatus::Fail);
00464 break;
00465 case vpr::SocketOptions::RecvBufferSize:
00466 status.setCode(vpr::ReturnStatus::Fail);
00467 break;
00468 case vpr::SocketOptions::SendBufferSize:
00469 status.setCode(vpr::ReturnStatus::Fail);
00470 break;
00471
00472 // IP-level options.
00473 case vpr::SocketOptions::IpTimeToLive:
00474 status.setCode(vpr::ReturnStatus::Fail);
00475 break;
00476 case vpr::SocketOptions::IpTypeOfService:
00477 status.setCode(vpr::ReturnStatus::Fail);
00478 break;
00479 case vpr::SocketOptions::AddMember:
00480 status.setCode(vpr::ReturnStatus::Fail);
00481 break;
00482 case vpr::SocketOptions::DropMember:
00483 status.setCode(vpr::ReturnStatus::Fail);
00484 break;
00485 case vpr::SocketOptions::McastInterface:
00486 status.setCode(vpr::ReturnStatus::Fail);
00487 break;
00488 case vpr::SocketOptions::McastTimeToLive:
00489 status.setCode(vpr::ReturnStatus::Fail);
00490 break;
00491 case vpr::SocketOptions::McastLoopback:
00492 status.setCode(vpr::ReturnStatus::Fail);
00493 break;
00494
00495 // TCP-level options.
00496 case vpr::SocketOptions::NoDelay:
00497 status.setCode(vpr::ReturnStatus::Fail);
00498 break;
00499 case vpr::SocketOptions::MaxSegment:
00500 status.setCode(vpr::ReturnStatus::Fail);
00501 break;
00502 }
00503
00504 return status;
00505 }
|
|
|
Tests if this socket can read without blocking.
Implemented in vpr::SocketDatagramImplSIM. |
|
|
Tests if this socket can write without blocking.
Implemented in vpr::SocketDatagramImplSIM. |
|
|
Tests if this socket is in an exceptional state.
Definition at line 507 of file SocketImplSIM.cpp. References vpr::ReturnStatus::Fail.
00508 {
00509 // XXX: For now, we never go into an exceptional state.
00510 return vpr::ReturnStatus(vpr::ReturnStatus::Fail);
00511 }
|
|
|
Definition at line 489 of file SocketImplSIM.h. References vprASSERT.
00490 {
00491 vprASSERT(msg->getDestinationSocket() == this && "Message delivered to incorrect destination");
00492 vpr::Guard<vpr::Mutex> guard(mArrivedQueueMutex);
00493 mArrivedQueue.push_back(msg);
00494 }
|
|
|
Definition at line 496 of file SocketImplSIM.h. References vpr::sim::NetworkGraph::VertexListPtr. Referenced by vpr::sim::SocketManager::findRoute.
00497 {
00498 mPathToPeer = path;
00499 }
|
|
|
Definition at line 501 of file SocketImplSIM.h. References vpr::sim::NetworkGraph::net_vertex_t. Referenced by vpr::sim::SocketManager::assignToNode.
00502 {
00503 mNetworkNode = node;
00504 }
|
|
|
Definition at line 506 of file SocketImplSIM.h. References vpr::sim::NetworkGraph::net_vertex_t. Referenced by vpr::sim::SocketManager::connect, vpr::sim::SocketManager::findRoute, and vpr::sim::SocketManager::sendMessageTo.
00507 {
00508 return mNetworkNode;
00509 }
|
|
|
Definition at line 544 of file SocketImplSIM.cpp. References setConnectState. Referenced by close.
00545 {
00546 // XXX: This is potentially not the best way to disconnect, but it's the
00547 // best I have come up with so far.
00548 setConnectState(NULL);
00549 }
|
|
|
Sets this socket's connected state using the given pointer value. Depending on the value, the connected state of thsi socket is updated accordingly.
Definition at line 549 of file SocketImplSIM.h. Referenced by completeConnection, and disconnect.
00550 {
00551 mPeer = peer;
00552 mConnected = (NULL != mPeer); // We are connected if mPeer is non-NULL
00553 }
|
|
|
Definition at line 513 of file SocketImplSIM.h. |
|
|
Definition at line 555 of file SocketImplSIM.h. |
|
|
Definition a |