C# Class Brunet.Messaging.IPHandler

IPHandler is provided to do BrunetRpc natively (as opposed to XmlRpc). This service provides for discovery similar to zeroconf. This was done due to zeroconf not being widespread enough to rely on it as well as too many ways to interface with the different implementations. Discovery runs at group address 224.123.123.222:56123.
Inheritance: SimpleSource
Show file Open project: pstjuste/brunet Class Usage Examples

Public Properties

Property Type Description
MagicCookie Brunet.Util.MemBlock
mc_addr System.Net.IPAddress
mc_endpoint System.Net.EndPoint
mc_port int

Protected Properties

Property Type Description
_listen_thread Thread
_mc Socket
_running int
_uc Socket

Public Methods

Method Description
CreateMulticastSender ( ) : ISender

Creates a new MulticastSender using the IPHandlers multicastcast socket. This sends to all network devices on the computer.

CreateMulticastSender ( IPAddress LocalIPAddresses ) : ISender

Creates a Multicast Sender using the unicast socket, so that other nodes know where they can reach us. Only sends to the addresses in the array.

CreateUnicastSender ( EndPoint ep ) : ISender

Creates a new UnicastSender using the IPHandlers unicast socket.

GetLocalIPAddresses ( ) : System.Net.IPAddress[]

Returns an array of all the IPAddresses of the local machine. Manually add loopback sense Windows does not have a loopback interface.

IPAddressToInt ( IPAddress addr ) : int

IPAddress.Address is obsolete, we use our own method to convert to an int in case the method is removed.

IPHandler ( ) : System

Creates a new IPHandler object by initializing the multicast and unicast socket.

The multicast socket is optional as nodes can discover other working nodes using only the unicast socket. The steps for setup for a multicast socket are bind to 0.0.0.0:port, add membership to all IP Addresses on the node, allow MulticastLoopback. The steps for the unicast socket are to create socket andbind to 0.0.0.0 and random port. Afterwhich the _listen_thread is started in the background.

Stop ( ) : void

Called to interrupt the _listen_thread.

Protected Methods

Method Description
Listen ( ) : void

The _listen_threads method, reads from sockets and let's the node handle the incoming data.

Method Details

CreateMulticastSender() public method

Creates a new MulticastSender using the IPHandlers multicastcast socket. This sends to all network devices on the computer.
public CreateMulticastSender ( ) : ISender
return ISender

CreateMulticastSender() public method

Creates a Multicast Sender using the unicast socket, so that other nodes know where they can reach us. Only sends to the addresses in the array.
public CreateMulticastSender ( IPAddress LocalIPAddresses ) : ISender
LocalIPAddresses System.Net.IPAddress The local ip addresses we should send on.
return ISender

CreateUnicastSender() public method

Creates a new UnicastSender using the IPHandlers unicast socket.
public CreateUnicastSender ( EndPoint ep ) : ISender
ep System.Net.EndPoint The remote network end point where the UnicastSender should send the data.
return ISender

GetLocalIPAddresses() public static method

Returns an array of all the IPAddresses of the local machine. Manually add loopback sense Windows does not have a loopback interface.
public static GetLocalIPAddresses ( ) : System.Net.IPAddress[]
return System.Net.IPAddress[]

IPAddressToInt() public static method

IPAddress.Address is obsolete, we use our own method to convert to an int in case the method is removed.
When not an IPv4 address.
public static IPAddressToInt ( IPAddress addr ) : int
addr System.Net.IPAddress The address to convert to an integer.
return int

IPHandler() public method

Creates a new IPHandler object by initializing the multicast and unicast socket.
The multicast socket is optional as nodes can discover other working nodes using only the unicast socket. The steps for setup for a multicast socket are bind to 0.0.0.0:port, add membership to all IP Addresses on the node, allow MulticastLoopback. The steps for the unicast socket are to create socket andbind to 0.0.0.0 and random port. Afterwhich the _listen_thread is started in the background.
public IPHandler ( ) : System
return System

Listen() protected method

The _listen_threads method, reads from sockets and let's the node handle the incoming data.
protected Listen ( ) : void
return void

Stop() public method

Called to interrupt the _listen_thread.
public Stop ( ) : void
return void

Property Details

MagicCookie public static property

public static MemBlock,Brunet.Util MagicCookie
return Brunet.Util.MemBlock

_listen_thread protected property

Thread dedicated to reading from the unicast and multicast sockets
protected Thread _listen_thread
return Thread

_mc protected property

Runs on 224.123.123.222:56123
protected Socket _mc
return Socket

_running protected property

The system is running and so should _listen_thread.
protected int _running
return int

_uc protected property

The unicast socket, the port is randomly selected.
protected Socket _uc
return Socket

mc_addr public static property

Multicast address.
public static IPAddress,System.Net mc_addr
return System.Net.IPAddress

mc_endpoint public static property

Multicast end point.
public static EndPoint,System.Net mc_endpoint
return System.Net.EndPoint

mc_port public static property

Multicast port.
public static int mc_port
return int