Changeset 21003
- Timestamp:
- 01/13/08 08:13:47 (8 months ago)
- Files:
-
- juggler/trunk/modules/vapor/ChangeLog (modified) (1 diff)
- juggler/trunk/modules/vapor/VERSION (modified) (1 diff)
- juggler/trunk/modules/vapor/vpr/IO/Socket/Makefile.in (modified) (1 diff)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketBasicOpt.h (deleted)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketDatagramOpt.cpp (deleted)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketDatagramOpt.h (deleted)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketDatagram_t.h (modified) (6 diffs)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketIpOpt.h (deleted)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketOptions.h (modified) (1 diff)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketStreamOpt.cpp (deleted)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketStreamOpt.h (deleted)
- juggler/trunk/modules/vapor/vpr/IO/Socket/SocketStream_t.h (modified) (8 diffs)
- juggler/trunk/modules/vapor/vpr/IO/Socket/Socket_t.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/vapor/ChangeLog
r20997 r21003 1 1 DATE AUTHOR CHANGE 2 2 ---------- -------- ----------------------------------------------------------- 3 2008-01-13 patrick Folded vpr::SocketBasicOpt and vpr::SocketIpOpt into 4 vpr::Socket_t<T>. Folded vpr::SocketStreamOpt into 5 vpr::SocketStream_t<T>. Folded vpr::SocketDatagramOpt into 6 vpr::SocketDatagram_t<T>. Removed vpr::SocketOptionWrapper. 7 NEW VERSION: 2.1.10 3 8 2008-01-12 patrick Extended vpr::SocketStream to support "corked" or no-push 4 9 writing. juggler/trunk/modules/vapor/VERSION
r20997 r21003 1 2.1.10-0 @01/13/2008 14:15:00 UTC@ 1 2 2.1.9-0 @01/12/2008 15:20:00 UTC@ 2 3 2.1.8-0 @10/30/2007 20:15:00 UTC@ juggler/trunk/modules/vapor/vpr/IO/Socket/Makefile.in
r21001 r21003 59 59 SocketAcceptor.cpp \ 60 60 SocketConnector.cpp \ 61 SocketDatagramOpt.cpp \62 61 SocketException.cpp \ 63 SocketStreamOpt.cpp \64 62 UnknownHostException.cpp 65 63 juggler/trunk/modules/vapor/vpr/IO/Socket/SocketDatagram_t.h
r20993 r21003 41 41 42 42 #include <vpr/IO/Socket/Socket_t.h> 43 #include <vpr/IO/Socket/SocketDatagramOpt.h>44 43 45 44 #include <boost/smart_ptr.hpp> … … 58 57 * 59 58 * @see vpr::SocketDatagramImplNSPR, vpr::SocketDatagramImplBSD 59 * 60 * @note vpr::SocketDatagramOpt was folded into this class in version 2.1.10. 61 * User-level code will most likely not be affected by this difference. 60 62 */ 61 63 template<class SocketConfig_> 62 64 class SocketDatagram_t 63 65 : public Socket_t<SocketConfig_> 64 , public SocketDatagramOpt65 66 { 66 67 public: … … 73 74 SocketDatagram_t() 74 75 : Socket_t<Config>() 75 , SocketDatagramOpt()76 76 , mSocketDgramImpl() 77 77 { … … 96 96 const vpr::InetAddr& remoteAddr) 97 97 : Socket_t<Config>() 98 , SocketDatagramOpt()99 98 { 100 99 mSocketDgramImpl = … … 111 110 SocketDatagram_t(const SocketDatagram_t& sock) 112 111 : Socket_t<Config>() 113 , SocketDatagramOpt()114 112 , mSocketDgramImpl(sock.mSocketDgramImpl) 115 113 { … … 214 212 } 215 213 216 protected: 217 /** 218 * @throw vpr::SocketException 219 * Thrown if querying the indiccated option on this socket fails. 220 */ 221 virtual void getOption(const vpr::SocketOptions::Types option, 222 struct vpr::SocketOptions::Data& data) 223 const 224 { 225 return mSocketDgramImpl->getOption(option, data); 226 } 227 228 /** 229 * @throw vpr::SocketException 230 * Thrown if setting the indicated option on this socket fails. 231 */ 232 virtual void setOption(const vpr::SocketOptions::Types option, 233 const struct vpr::SocketOptions::Data& data) 234 { 235 mSocketDgramImpl->setOption(option, data); 236 } 214 /** @name Socket Options */ 215 //@{ 216 /** 217 * Gets the multicast interface for this datagram socket. 218 * 219 * @throw vpr::SocketException Thrown if the operation failed. 220 */ 221 const vpr::InetAddr getMcastInterface() const 222 { 223 vpr::SocketOptions::Data option; 224 225 this->getOption(SocketOptions::McastInterface, option); 226 return option.mcast_if; 227 } 228 229 /** 230 * Sets the multicast interface for this datagram socket. 231 * 232 * @throw vpr::SocketException Thrown if the operation failed. 233 */ 234 void setMcastInterface(const vpr::InetAddr& mcastIf) 235 { 236 vpr::SocketOptions::Data option; 237 option.mcast_if = mcastIf; 238 this->setOption(SocketOptions::McastInterface, option); 239 } 240 241 /** 242 * Gets the multicast time-to-live parameter for packets sent on this 243 * socket. 244 * 245 * @throw vpr::SocketException Thrown if the operation failed. 246 */ 247 vpr::Uint8 getMcastTimeToLive() const 248 { 249 vpr::SocketOptions::Data option; 250 251 this->getOption(SocketOptions::McastTimeToLive, option); 252 return option.mcast_ttl; 253 } 254 255 /** 256 * Sets the multicast time-to-live parameter for packets sent on this 257 * socket. 258 * 259 * @throw vpr::SocketException Thrown if the operation failed. 260 */ 261 void setMcastTimeToLive(const vpr::Uint8 ttl) 262 { 263 vpr::SocketOptions::Data option; 264 option.mcast_ttl = ttl; 265 this->setOption(SocketOptions::McastTimeToLive, option); 266 } 267 268 /** 269 * @throw vpr::SocketException Thrown if the operation failed. 270 */ 271 vpr::Uint8 getMcastLoopback() const 272 { 273 vpr::SocketOptions::Data option; 274 275 this->getOption(SocketOptions::McastLoopback, option); 276 return option.mcast_loopback; 277 } 278 279 /** 280 * @throw vpr::SocketException Thrown if the operation failed. 281 */ 282 void setMcastLoopback(const vpr::Uint8 loop) 283 { 284 vpr::SocketOptions::Data option; 285 option.mcast_loopback = loop; 286 this->setOption(SocketOptions::McastLoopback, option); 287 } 288 289 /** 290 * @throw vpr::IOException Thrown if the operation failed. 291 */ 292 void addMcastMember(const vpr::McastReq& request) 293 { 294 vpr::SocketOptions::Data option; 295 option.mcast_add_member = request; 296 this->setOption(SocketOptions::AddMember, option); 297 } 298 299 /** 300 * @throw vpr::IOException Thrown if the operation failed. 301 */ 302 void dropMcastMember(const vpr::McastReq& request) 303 { 304 vpr::SocketOptions::Data option; 305 option.mcast_drop_member = request; 306 this->setOption(SocketOptions::DropMember, option); 307 } 308 309 /** 310 * @throw vpr::IOException Thrown if the operation failed. 311 * @since 1.1.17 312 */ 313 void setBroadcast(const bool val) 314 { 315 vpr::SocketOptions::Data option; 316 option.broadcast = val; 317 this->setOption(SocketOptions::Broadcast, option); 318 } 319 //@} 237 320 238 321 // Put in back door for simulator juggler/trunk/modules/vapor/vpr/IO/Socket/SocketOptions.h
r20997 r21003 125 125 } 126 126 127 /** \class SocketOptionWrapper SocketOptions.h vpr/IO/Socket/SocketOptions.h128 *129 * Simple interface for setting and querying socket options.130 */131 class VPR_CLASS_API SocketOptionWrapper132 {133 public:134 virtual ~SocketOptionWrapper()135 {136 /* Do nothing. */ ;137 }138 139 protected:140 /**141 * Retrieves the value for the given option as set on the socket.142 *143 * @param option The option to be queried.144 * @param data A data buffer that will be used to store the value of the145 * given option.146 *147 * @throws vpr::SocketException if the value for the given option148 * could not be retrieved.149 */150 virtual void getOption(const vpr::SocketOptions::Types option,151 struct vpr::SocketOptions::Data& data) const = 0;152 153 /**154 * Sets a value for the given option on the socket using the given data155 * block.156 *157 * @param option The option whose value will be set.158 * @param data A data buffer containing the value to be used in setting159 * the socket option.160 *161 * @throws vpr::SocketException if the value for the given option162 * could not be set.163 */164 virtual void setOption(const vpr::SocketOptions::Types option,165 const struct vpr::SocketOptions::Data& data) = 0;166 };167 168 127 } // End of vpr namespace 169 128 juggler/trunk/modules/vapor/vpr/IO/Socket/SocketStream_t.h
r21002 r21003 40 40 #include <vpr/vprConfig.h> 41 41 42 #include <vpr/IO/Socket/SocketStreamOpt.h>43 42 #include <vpr/IO/Socket/Socket_t.h> /* base bridge class.. */ 44 43 … … 58 57 * 59 58 * @see vpr::SocketStreamImplNSPR, vpr::SocketStreamImplBSD 59 * 60 * @note vpr::SocketStreamOpt was folded into this class in version 2.1.10. 61 * User-level code will most likely not be affected by this difference. 60 62 */ 61 63 //template<class RealSocketStreamImpl, class RealSocketStreamImplParent, class IO_STATS_STRATEGY = NullIOStatsStrategy> 62 64 //class SocketStream_t : public Socket_t<RealSocketStreamImplParent, IO_STATS_STRATEGY>, 63 65 template<class SocketConfig_> 64 class SocketStream_t : public Socket_t<SocketConfig_> , public SocketStreamOpt66 class SocketStream_t : public Socket_t<SocketConfig_> 65 67 { 66 68 public: … … 108 110 SocketStream_t(const SocketStream_t& sock) 109 111 : Socket_t<SocketConfig_>() 110 , SocketStreamOpt()111 112 , mSocketStreamImpl(sock.mSocketStreamImpl) 112 113 { … … 207 208 } 208 209 210 /** @name Socket Options */ 211 //@{ 212 /** 213 * 214 */ 215 size_t getMaxSegmentSize() const 216 { 217 vpr::SocketOptions::Data option; 218 219 this->getOption(vpr::SocketOptions::MaxSegment, option); 220 return option.max_segment; 221 } 222 223 /** 224 * 225 */ 226 void setMaxSegmentSize(const vpr::Int32 size) 227 { 228 vpr::SocketOptions::Data option; 229 option.max_segment = size; 230 this->setOption(vpr::SocketOptions::MaxSegment, option); 231 } 232 233 /** @name Nagle Algorithm Control */ 234 //@{ 235 /** 236 * Gets the current no-delay status for this socket. If no-delay is true, 237 * then the Nagle algorithm has been disabled. 238 * 239 * @return \c true is returned if the Nabel algorithm is \em not being used 240 * to delay the transmission of TCP segments. Otherwise, the Nagle 241 * algorithm is delaying the transmission. 242 */ 243 bool getNoDelay() const 244 { 245 vpr::SocketOptions::Data option; 246 247 this->getOption(vpr::SocketOptions::NoDelay, option); 248 return option.no_delay; 249 } 250 251 /** 252 * Sets the current no-delay status for this socket. If no-delay is true, 253 * then the Nagle algorithm will be disabled. 254 * 255 * @param enableVal The Boolean enable/disable state for no-delay on this 256 * socket. 257 */ 258 void setNoDelay(const bool enableVal) 259 { 260 vpr::SocketOptions::Data option; 261 option.no_delay = enableVal; 262 this->setOption(vpr::SocketOptions::NoDelay, option); 263 } 264 //@} 265 266 /** @name TCP Corking Interface */ 267 //@{ 268 /** 269 * Gets the state of the "no push" or "corking" for this socket. While a 270 * TCP socket is in the corked state, write operations are queued for 271 * later transmission when the socket is uncorked (that is, when the 272 * no-push state is disabled). 273 * 274 * @return true is returned if this socket is currently in the no-push 275 * (corked) state. false is returned otherwise. 276 * 277 * @since 2.1.9 278 */ 279 bool getNoPush() const 280 { 281 #if defined(HAVE_CORKABLE_TCP) 282 vpr::SocketOptions::Data option; 283 284 this->getOption(vpr::SocketOptions::NoPush, option); 285 return option.no_push; 286 #else 287 return mCorked; 288 #endif 289 } 290 291 /** 292 * Enables or disables the no-push (or "corked") state. 293 * 294 * @post If this socket was previously in the corked state and the value of 295 * \p enableVal is false, then all queued buffer writes will be 296 * performed. 297 * 298 * @param enableVal A boolean value indicating whether this socket should 299 * be in the no-push (corked) state. 300 * 301 * @since 2.1.9 302 */ 303 void setNoPush(const bool enableVal) 304 { 305 // NSPR sockets are not corkable, but the OS may still support TCP corking. 306 #if defined(HAVE_CORKABLE_TCP) && VPR_IO_DOMAIN_INCLUDE != VPR_DOMAIN_NSPR 307 vpr::SocketOptions::Data option; 308 option.no_push = enableVal; 309 this->setOption(vpr::SocketOptions::NoPush, option); 310 #else 311 if ( enableVal != mCorked ) 312 { 313 // Changing from the uncorked state to the corked state. 314 if ( enableVal ) 315 { 316 mSocketStreamImpl->cork(); 317 } 318 // Changing from the corked state to the uncorked state. 319 else 320 { 321 mSocketStreamImpl->uncork(); 322 } 323 } 324 #endif 325 326 mCorked = enableVal; 327 } 328 209 329 /** 210 330 * Changes the strategy used for determining hwo much memory to allocate … … 223 343 mSocketStreamImpl->setCorkAllocStrategy(s); 224 344 } 345 //@} 346 347 //@} 225 348 226 349 protected: … … 242 365 243 366 /** 244 * @throw vpr::SocketException245 * Thrown if querying the indiccated option on this socket fails.246 */247 virtual void getOption(const vpr::SocketOptions::Types option,248 struct vpr::SocketOptions::Data& data)249 const250 {251 mSocketStreamImpl->getOption(option, data);252 }253 254 /**255 * @throw vpr::SocketException256 * Thrown if setting the indicated option on this socket fails.257 */258 virtual void setOption(const vpr::SocketOptions::Types option,259 const struct vpr::SocketOptions::Data& data)260 {261 mSocketStreamImpl->setOption(option, data);262 }263 264 /**265 367 * @name TCP Corking Interface Implementation 266 368 * … … 268 370 */ 269 371 //@{ 270 /**271 * Calls through to the cork() method of the internal stream socket272 * implementation.273 *274 * @since 2.1.9275 *276 * @see vpr::SocketStreamImplBSD::cork()277 * @see vpr::SocketStreamImplNSPR::cork()278 */279 virtual void cork()280 {281 mSocketStreamImpl->cork();282 }283 284 /**285 * Calls through to the uncork() method of the internal stream socket286 * implementation.287 *288 * @since 2.1.9289 *290 * @see vpr::SocketStreamImplBSD::uncork()291 * @see vpr::SocketStreamImplNSPR::uncork()292 */293 virtual void uncork()294 {295 mSocketStreamImpl->uncork();296 }297 //@}298 299 372 // Put in back door for simulator 300 373 #if VPR_IO_DOMAIN_INCLUDE == VPR_DOMAIN_SIMULATOR … … 303 376 /// Platform-specific stream socket implementation 304 377 boost::shared_ptr<SocketStreamImpl> mSocketStreamImpl; 378 379 private: 380 bool mCorked; 305 381 }; 306 382 juggler/trunk/modules/vapor/vpr/IO/Socket/Socket_t.h
r20974 r21003 46 46 #include <vpr/IO/IOSys.h> 47 47 #include <vpr/IO/Socket/SocketOptions.h> 48 #include <vpr/IO/Socket/SocketIpOpt.h>49 48 50 49 #include <vpr/Util/Interval.h> … … 73 72 * @see vpr::SocketStream_t, vpr::SocketDatagram_t, vpr::SocketImplNSPR, 74 73 * vpr::SocketImplBSD 74 * 75 * @note vpr::SocketBasicOpt and vpr::SocketIpOpt were folded into this class 76 * in version 2.1.10. User-level code will most likely not be affected 77 * by this difference. 75 78 */ 76 79 //template<class RealSocketImpl, class IO_STATS_STRATEGY = NullIOStatsStrategy> 77 80 template<class SockConfig_> 78 class Socket_t : public vpr::BlockIO , public vpr::SocketIpOpt81 class Socket_t : public vpr::BlockIO 79 82 { 80 83 public: … … 596 599 mSocketImpl->setRemoteAddr(addr); 597 600 } 601 602 /** @name Socket Options */ 603 //@{ 604 /** 605 * @throw vpr::SocketException Thrown if the operation failed. 606 */ 607 bool getKeepAlive() const 608 { 609 vpr::SocketOptions::Data option; 610 611 getOption(vpr::SocketOptions::KeepAlive, option); 612 613 return option.keep_alive; 614 } 615 616 /** 617 * @throw vpr::SocketException Thrown if the operation failed. 618 */ 619 void setKeepAlive(const bool enableVal) 620 { 621 vpr::SocketOptions::Data option; 622 option.keep_alive = enableVal; 623 setOption(vpr::SocketOptions::KeepAlive, option); 624 } 625 626 /** 627 * @throw vpr::SocketException Thrown if the operation failed. 628 */ 629 void getLingerOnClose(bool& enabled, int& lingerSec) const 630 { 631 vpr::SocketOptions::Data opt; 632 633 getOption(vpr::SocketOptions::Linger, opt); 634 635 enabled = opt.linger.enabled; 636 lingerSec = opt.linger.seconds; 637 } 638 639 /** 640 * @throw vpr::SocketException Thrown if the operation failed. 641 */ 642 void setLingerOnClose(const bool enableVal, 643 const int lingerSec) 644 { 645 vpr::SocketOptions::Data opt; 646 647 opt.linger.enabled = enableVal; 648 opt.linger.seconds = lingerSec; 649 650 setOption(vpr::SocketOptions::Linger, opt); 651 } 652 653 /** 654 * @throw vpr::SocketException Thrown if the operation failed. 655 */ 656 size_t getRecvBufferSize() const 657 { 658 vpr::SocketOptions::Data opt; 659 660 getOption(vpr::SocketOptions::RecvBufferSize, opt); 661 662 return opt.recv_buffer_size; 663 } 664 665 /** 666 * @throw vpr::SocketException Thrown if the operation failed. 667 */ 668 void setRecvBufferSize(const Int32 size) 669 { 670 vpr::SocketOptions::Data opt; 671 672 opt.recv_buffer_size = size; 673 674 setOption(vpr::SocketOptions::RecvBufferSize, opt); 675 } 676 677 /** 678 * @throw vpr::SocketException Thrown if the operation failed. 679 */ 680 size_t getSendBufferSize() const 681 { 682 vpr::SocketOptions::Data opt; 683 684 getOption(vpr::SocketOptions::SendBufferSize, opt); 685 686 return opt.send_buffer_size; 687 } 688 689 /** 690 * @throw vpr::SocketException Thrown if the operation failed. 691 */ 692 void setSendBufferSize(const Int32 size) 693 { 694 vpr::SocketOptions::Data opt; 695 696 opt.send_buffer_size = size; 697 698 setOption(vpr::SocketOptions::SendBufferSize, opt); 699 } 700 701 /** 702 * @throw vpr::SocketException Thrown if the operation failed. 703 */ 704 bool getReuseAddr() const 705 { 706 vpr::SocketOptions::Data option; 707 708 getOption(vpr::SocketOptions::ReuseAddr, option); 709 710 return option.reuse_addr; 711 } 712 713 /** 714 * Enables reuse of the address that will be bound by the socket. 715 * 716 * @pre The socket has been opened, but bind() has not been called. 717 * 718 * @throw vpr::SocketException Thrown if the operation failed. 719 */ 720 void setReuseAddr(const bool enableVal) 721 { 722 vpr::SocketOptions::Data option; 723 option.reuse_addr = enableVal; 724 setOption(vpr::SocketOptions::ReuseAddr, option); 725 } 726 727 /** 728 * @throw vpr::SocketException Thrown if the operation failed. 729 */ 730 vpr::SocketOptions::TypeOfService getTypeOfService() const 731 { 732 vpr::SocketOptions::Data option; 733 734 getOption(vpr::SocketOptions::IpTypeOfService, option); 735 return option.type_of_service; 736 } 737 738 /** 739 * @throw vpr::SocketException Thrown if the operation failed. 740 */ 741 void setTypeOfService(const vpr::SocketOptions::TypeOfService& tos) 742 { 743 vpr::SocketOptions::Data option; 744 option.type_of_service = tos; 745 setOption(vpr::SocketOptions::IpTypeOfService, option); 746 } 747 748 /** 749 * @throw vpr::SocketException Thrown if the operation failed. 750 */ 751 vpr::Int32 getTimeToLive() const 752 { 753 vpr::SocketOptions::Data option; 754 755 getOption(vpr::SocketOptions::IpTimeToLive, option); 756 return option.ip_ttl; 757 } 758 759 /** 760 * @throw vpr::SocketException Thrown if the operation failed. 761 */ 762 void setTimeToLive(const vpr::Int32 ttl) 763 { 764 vpr::SocketOptions::Data option; 765 option.ip_ttl = ttl; 766 setOption(vpr::SocketOptions::IpTimeToLive, option); 767 } 768 //@} 598 769 599 770 protected: … … 756 927 } 757 928 758 virtual void getOption(const vpr::SocketOptions::Types option, 759 struct vpr::SocketOptions::Data& data) const 929 /** 930 * Retrieves the value for the given option as set on the socket. 931 * 932 * @param option The option to be queried. 933 * @param data A data buffer that will be used to store the value of the 934 * given option. 935 * 936 * @throw vpr::SocketException 937 * Thrown if the value for the given option could not be 938 * retrieved. 939 */ 940 void getOption(const vpr::SocketOptions::Types option, 941 struct vpr::SocketOptions::Data& data) const 760 942 { 761 943 mSocketImpl->getOption(option, data); 762 944 } 763 945 764 virtual void setOption(const vpr::SocketOptions::Types option, 765 const struct vpr::SocketOptions::Data& data) 946 /** 947 * Sets a value for the given option on the socket using the given data 948 * block. 949 * 950 * @param option The option whose value will be set. 951 * @param data A data buffer containing the value to be used in setting 952 * the socket option. 953 * 954 * @throw vpr::SocketException 955 * Thrown if the value for the given option could not be set. 956 */ 957 void setOption(const vpr::SocketOptions::Types option, 958 const struct vpr::SocketOptions::Data& data) 766 959 { 767 960 mSocketImpl->setOption(option, data);
