Socket Class Reference

#include <NetInterface.hh>

Inheritance diagram for Socket:

Inheritance graph
Collaboration diagram for Socket:

Collaboration graph

Public Member Functions

virtual ~Socket ()
void reset ()
virtual Boolean handleRead (unsigned char *buffer, unsigned bufferMaxSize, unsigned &bytesRead, struct sockaddr_in &fromAddress)=0
int socketNum () const
Port port () const
UsageEnvironmentenv () const

Static Public Attributes

static int DebugLevel = 1
static UsageEnvironmentDefaultUsageEnvironment = NULL

Protected Member Functions

 Socket (UsageEnvironment &env, Port port)
Boolean changePort (Port newPort)

Private Attributes

int fSocketNum
Port fPort

Detailed Description

Definition at line 80 of file NetInterface.hh.

Constructor & Destructor Documentation

Socket::~Socket (  )  [virtual]

Definition at line 98 of file NetInterface.cpp.

References reset().

00098                 {
00099   reset();
00100 }

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

Definition at line 88 of file NetInterface.cpp.

References fEnv, fSocketNum, port(), and setupDatagramSocket().

Member Function Documentation

void Socket::reset (  ) 

Definition at line 93 of file NetInterface.cpp.

References closeSocket, and fSocketNum.

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

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

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

Implemented in OutputSocket, and Groupsock.

Referenced by socketReadHandler().

int Socket::socketNum (  )  const [inline]

Definition at line 90 of file NetInterface.hh.

References 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(), OutputSocket::write(), BasicUDPSource::~BasicUDPSource(), and Groupsock::~Groupsock().

00090 { return fSocketNum; }

Port Socket::port (  )  const [inline]

Definition at line 92 of file NetInterface.hh.

References fPort.

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

00092                     {
00093     return fPort;
00094   }

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

Definition at line 96 of file NetInterface.hh.

References fEnv.

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

00096 { return fEnv; }

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

Definition at line 102 of file NetInterface.cpp.

References closeSocket, False, fEnv, 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);
00108   fSocketNum = setupDatagramSocket(fEnv, newPort);
00109   if (fSocketNum < 0) {
00110     fEnv.taskScheduler().turnOffBackgroundReadHandling(oldSocketNum);
00111     return False;
00112   }
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

int Socket::DebugLevel = 1 [static]

Definition at line 98 of file NetInterface.hh.

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

int Socket::fSocketNum [private]

Definition at line 106 of file NetInterface.hh.

Referenced by changePort(), reset(), Socket(), and socketNum().

UsageEnvironment& Socket::fEnv [private]

Definition at line 107 of file NetInterface.hh.

Referenced by changePort(), env(), and Socket().

Port Socket::fPort [private]

Definition at line 108 of file NetInterface.hh.

Referenced by port().

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 Tue Mar 25 14:40:54 2014 for live by  doxygen 1.5.2