OutputSocket Class Reference

#include <Groupsock.hh>

Inheritance diagram for OutputSocket:

Inheritance graph
[legend]
Collaboration diagram for OutputSocket:

Collaboration graph
[legend]

Public Member Functions

 OutputSocket (UsageEnvironment &env)
virtual ~OutputSocket ()
Boolean write (netAddressBits address, Port port, u_int8_t ttl, unsigned char *buffer, unsigned bufferSize)
void reset ()
int socketNum () const
Port port () const
UsageEnvironmentenv () const

Static Public Attributes

static int DebugLevel = 1
static UsageEnvironmentDefaultUsageEnvironment = NULL

Protected Member Functions

 OutputSocket (UsageEnvironment &env, Port port)
portNumBits sourcePortNum () const
Boolean changePort (Port newPort)

Private Member Functions

virtual Boolean handleRead (unsigned char *buffer, unsigned bufferMaxSize, unsigned &bytesRead, struct sockaddr_in &fromAddress)

Private Attributes

Port fSourcePort
unsigned fLastSentTTL

Detailed Description

Definition at line 39 of file Groupsock.hh.


Constructor & Destructor Documentation

OutputSocket::OutputSocket ( UsageEnvironment env  ) 

Definition at line 32 of file Groupsock.cpp.

00033   : Socket(env, 0 /* let kernel choose port */),
00034     fSourcePort(0), fLastSentTTL(256/*hack: a deliberately invalid value*/) {
00035 }

OutputSocket::~OutputSocket (  )  [virtual]

Definition at line 42 of file Groupsock.cpp.

00042                             {
00043 }

OutputSocket::OutputSocket ( UsageEnvironment env,
Port  port 
) [protected]

Definition at line 37 of file Groupsock.cpp.

00038   : Socket(env, port),
00039     fSourcePort(0), fLastSentTTL(256/*hack: a deliberately invalid value*/) {
00040 }


Member Function Documentation

Boolean OutputSocket::write ( netAddressBits  address,
Port  port,
u_int8_t  ttl,
unsigned char *  buffer,
unsigned  bufferSize 
)

Definition at line 45 of file Groupsock.cpp.

References Socket::DebugLevel, Socket::env(), False, fLastSentTTL, fSourcePort, UsageEnvironment::getResultMsg(), getSourcePort(), Socket::port(), Socket::socketNum(), sourcePortNum(), True, and writeSocket().

Referenced by Groupsock::output().

00046                                                                         {
00047   struct in_addr destAddr; destAddr.s_addr = address;
00048   if ((unsigned)ttl == fLastSentTTL) {
00049     // Optimization: Don't do a 'set TTL' system call again
00050     if (!writeSocket(env(), socketNum(), destAddr, port, buffer, bufferSize)) return False;
00051   } else {
00052     if (!writeSocket(env(), socketNum(), destAddr, port, ttl, buffer, bufferSize)) return False;
00053     fLastSentTTL = (unsigned)ttl;
00054   }
00055 
00056   if (sourcePortNum() == 0) {
00057     // Now that we've sent a packet, we can find out what the
00058     // kernel chose as our ephemeral source port number:
00059     if (!getSourcePort(env(), socketNum(), fSourcePort)) {
00060       if (DebugLevel >= 1)
00061         env() << *this
00062              << ": failed to get source port: "
00063              << env().getResultMsg() << "\n";
00064       return False;
00065     }
00066   }
00067 
00068   return True;
00069 }

portNumBits OutputSocket::sourcePortNum (  )  const [inline, protected]

Definition at line 50 of file Groupsock.hh.

References fSourcePort, and Port::num().

Referenced by Groupsock::wasLoopedBackFromUs(), and write().

00050 {return fSourcePort.num();}

Boolean OutputSocket::handleRead ( unsigned char *  buffer,
unsigned  bufferMaxSize,
unsigned &  bytesRead,
struct sockaddr_in &  fromAddress 
) [private, virtual]

Implements Socket.

Reimplemented in Groupsock.

Definition at line 73 of file Groupsock.cpp.

References True.

00074                                                                            {
00075   return True;
00076 }

void Socket::reset (  )  [inherited]

Definition at line 93 of file NetInterface.cpp.

References closeSocket, and Socket::fSocketNum.

Referenced by RTPInterface::setStreamSocket(), and Socket::~Socket().

00093                    {
00094   closeSocket(fSocketNum);
00095   fSocketNum = -1;
00096 }

int Socket::socketNum (  )  const [inline, inherited]

Definition at line 90 of file NetInterface.hh.

References Socket::fSocketNum.

Referenced by GroupsockLookupTable::AddNew(), RTCPInstance::addStreamSocket(), BasicUDPSource::BasicUDPSource(), Groupsock::changeDestinationParameters(), continueAfterDESCRIBE(), BasicUDPSource::doGetNextFrame(), BasicUDPSource::doStopGettingFrames(), SocketLookupTable::Fetch(), OnDemandServerMediaSubsession::getStreamParameters(), Groupsock::Groupsock(), Groupsock::handleRead(), MediaSubsession::initiate(), SIPClient::invite1(), Groupsock::multicastSendOnly(), MultiFramedRTPSource::MultiFramedRTPSource(), operator<<(), RTPInterface::RTPInterface(), RTPInterface::setStreamSocket(), SIPClient::SIPClient(), RTPInterface::startNetworkReading(), PassiveServerMediaSubsession::startStream(), RTPInterface::stopNetworkReading(), unsetGroupsockBySocket(), write(), BasicUDPSource::~BasicUDPSource(), and Groupsock::~Groupsock().

00090 { return fSocketNum; }

Port Socket::port (  )  const [inline, inherited]

Definition at line 92 of file NetInterface.hh.

References Socket::fPort.

Referenced by Groupsock::addDestination(), PassiveServerMediaSubsession::getStreamParameters(), Groupsock::Groupsock(), operator<<(), SocketLookupTable::Remove(), GroupsockLookupTable::Remove(), Groupsock::removeDestination(), PassiveServerMediaSubsession::sdpLines(), Socket::Socket(), and write().

00092                     {
00093     return fPort;
00094   }

UsageEnvironment& Socket::env (  )  const [inline, inherited]

Definition at line 96 of file NetInterface.hh.

References Socket::fEnv.

Referenced by Groupsock::changeDestinationParameters(), getGroupsockBySocket(), getSocketTable(), Groupsock::Groupsock(), Groupsock::handleRead(), Groupsock::multicastSendOnly(), Groupsock::output(), Groupsock::outputToAllMembersExcept(), setGroupsockBySocket(), socketReadHandler(), unsetGroupsockBySocket(), Groupsock::wasLoopedBackFromUs(), write(), and Groupsock::~Groupsock().

00096 { return fEnv; }

Boolean Socket::changePort ( Port  newPort  )  [protected, inherited]

Definition at line 102 of file NetInterface.cpp.

References closeSocket, False, Socket::fEnv, Socket::fSocketNum, getReceiveBufferSize(), getSendBufferSize(), TaskScheduler::moveSocketHandling(), setReceiveBufferTo(), setSendBufferTo(), setupDatagramSocket(), UsageEnvironment::taskScheduler(), True, and TaskScheduler::turnOffBackgroundReadHandling().

Referenced by Groupsock::changeDestinationParameters().

00102                                        {
00103   int oldSocketNum = fSocketNum;
00104   unsigned oldReceiveBufferSize = getReceiveBufferSize(fEnv, fSocketNum);
00105   unsigned oldSendBufferSize = getSendBufferSize(fEnv, fSocketNum);
00106   closeSocket(fSocketNum);
00107 
00108   fSocketNum = setupDatagramSocket(fEnv, newPort);
00109   if (fSocketNum < 0) {
00110     fEnv.taskScheduler().turnOffBackgroundReadHandling(oldSocketNum);
00111     return False;
00112   }
00113 
00114   setReceiveBufferTo(fEnv, fSocketNum, oldReceiveBufferSize);
00115   setSendBufferTo(fEnv, fSocketNum, oldSendBufferSize);
00116   if (fSocketNum != oldSocketNum) { // the socket number has changed, so move any event handling for it:
00117     fEnv.taskScheduler().moveSocketHandling(oldSocketNum, fSocketNum);
00118   }
00119   return True;
00120 }


Field Documentation

Port OutputSocket::fSourcePort [private]

Definition at line 58 of file Groupsock.hh.

Referenced by sourcePortNum(), and write().

unsigned OutputSocket::fLastSentTTL [private]

Definition at line 59 of file Groupsock.hh.

Referenced by write().

int Socket::DebugLevel = 1 [static, inherited]

Definition at line 98 of file NetInterface.hh.

Referenced by Groupsock::Groupsock(), Groupsock::handleRead(), Groupsock::output(), Groupsock::wasLoopedBackFromUs(), write(), and Groupsock::~Groupsock().

UsageEnvironment * NetInterface::DefaultUsageEnvironment = NULL [static, inherited]

Definition at line 32 of file NetInterface.hh.


The documentation for this class was generated from the following files:
Generated on Wed Apr 23 16:17:05 2014 for live by  doxygen 1.5.2