A Discrete-Event Network Simulator
API
Public Member Functions | List of all members
INetStreamSocket Struct Referenceabstract

Struct interface to NSC Stream (i.e., TCP) Sockets. More...

#include "sim_interface.h"

Public Member Functions

virtual ~INetStreamSocket ()
 
virtual int accept (INetStreamSocket **handler)=0
 Accept an incoming connection. More...
 
virtual void connect (const char *, int)=0
 Connect to a remote peer. More...
 
virtual void disconnect ()=0
 Disconnect from a remote peer. More...
 
virtual bool get_var (const char *var, char *result, int result_len)
 Optional function used to get variables for this TCP connection. More...
 
virtual int getpeername (struct sockaddr *sa, size_t *salen)
 Get the peer name. More...
 
virtual int getsockname (struct sockaddr *sa, size_t *salen)
 Get the socket local name. More...
 
virtual bool is_connected ()=0
 Check the connection state. More...
 
virtual bool is_listening ()=0
 Check the listening state. More...
 
virtual void listen (int)=0
 Put the socket in Listening state on a port. More...
 
virtual void print_state (FILE *)=0
 Print the socket state. More...
 
virtual int read_data (void *buf, int *buflen)=0
 Read some data. More...
 
virtual int send_data (const void *data, int datalen)=0
 Send some data. More...
 
virtual bool set_var (const char *var, const char *val)
 Optional function used to set variables for this TCP connection. More...
 
virtual int setsockopt (char *optname, void *val, size_t valsize)=0
 Set the socket options. More...
 

Detailed Description

Struct interface to NSC Stream (i.e., TCP) Sockets.

Definition at line 259 of file sim_interface.h.

Constructor & Destructor Documentation

◆ ~INetStreamSocket()

virtual INetStreamSocket::~INetStreamSocket ( )
inlinevirtual

Definition at line 261 of file sim_interface.h.

Member Function Documentation

◆ accept()

virtual int INetStreamSocket::accept ( INetStreamSocket **  handler)
pure virtual

Accept an incoming connection.

Parameters
handlera handler to the INetStreamSocket.
Returns
The status code.

Referenced by ns3::NscTcpSocketImpl::Accept().

◆ connect()

virtual void INetStreamSocket::connect ( const char *  ,
int   
)
pure virtual

Connect to a remote peer.

Referenced by ns3::NscTcpSocketImpl::Connect().

◆ disconnect()

virtual void INetStreamSocket::disconnect ( )
pure virtual

Disconnect from a remote peer.

Referenced by ns3::NscTcpSocketImpl::Close(), and ns3::NscTcpSocketImpl::SendPendingData().

◆ get_var()

virtual bool INetStreamSocket::get_var ( const char *  var,
char *  result,
int  result_len 
)
inlinevirtual

Optional function used to get variables for this TCP connection.

Note
not implemented
Parameters
varvariable requested
resultresult result
result_lenresult length
Returns
always false

Definition at line 356 of file sim_interface.h.

◆ getpeername()

virtual int INetStreamSocket::getpeername ( struct sockaddr *  sa,
size_t *  salen 
)
inlinevirtual

Get the peer name.

Note
not implemented
Parameters
sasockaddr structure to fill
salensockaddr structure length
Returns
-1 on error (always returns -1)

Definition at line 331 of file sim_interface.h.

Referenced by ns3::NscTcpSocketImpl::CompleteFork().

◆ getsockname()

virtual int INetStreamSocket::getsockname ( struct sockaddr *  sa,
size_t *  salen 
)
inlinevirtual

Get the socket local name.

Note
not implemented
Parameters
sasockaddr structure to fill
salensockaddr structure length
Returns
-1 on error (always returns -1)

Definition at line 343 of file sim_interface.h.

Referenced by ns3::NscTcpSocketImpl::CompleteFork(), and ns3::NscTcpSocketImpl::ConnectionSucceeded().

◆ is_connected()

virtual bool INetStreamSocket::is_connected ( )
pure virtual

Check the connection state.

Returns
true if socket is in connected state

Referenced by ns3::NscTcpSocketImpl::NSCWakeup().

◆ is_listening()

virtual bool INetStreamSocket::is_listening ( )
pure virtual

Check the listening state.

Returns
true if socket is in listening state

Referenced by ns3::NscTcpSocketImpl::Accept().

◆ listen()

virtual void INetStreamSocket::listen ( int  )
pure virtual

Put the socket in Listening state on a port.

Referenced by ns3::NscTcpSocketImpl::Listen().

◆ print_state()

virtual void INetStreamSocket::print_state ( FILE *  )
pure virtual

Print the socket state.

◆ read_data()

virtual int INetStreamSocket::read_data ( void *  buf,
int *  buflen 
)
pure virtual

Read some data.

Parameters
bufthe buffer to store the data
buflenbuffer length
Returns
the number of data read or -1 on error

Referenced by ns3::NscTcpSocketImpl::ReadPendingData().

◆ send_data()

virtual int INetStreamSocket::send_data ( const void *  data,
int  datalen 
)
pure virtual

Send some data.

Parameters
datathe data
datalendata length
Returns
the number of data sent or -1 on error

Referenced by ns3::NscTcpSocketImpl::SendPendingData().

◆ set_var()

virtual bool INetStreamSocket::set_var ( const char *  var,
const char *  val 
)
inlinevirtual

Optional function used to set variables for this TCP connection.

Note
not implemented
Parameters
varvariable to set
valvalue to set
Returns
always false

Definition at line 369 of file sim_interface.h.

◆ setsockopt()

virtual int INetStreamSocket::setsockopt ( char *  optname,
void *  val,
size_t  valsize 
)
pure virtual

Set the socket options.

We need to pass the option name in as a string here. The reason for this is that different operating systems you compile on will have different numbers defined for the constants SO_SNDBUF and so on.

Parameters
optnamename of the option
valoption value
valsizesize of the option value
Returns

The documentation for this struct was generated from the following file: