public static StartForward ( |
||
Interface_Addres | ||
Multicast_Address | ||
PortNumber | int | |
Frwd_Interface_Addres | ||
Frwd_Multicast_Address | ||
Frwd_PortNumber | int | |
return | bool |
public static bool StartForward(IPAddress Interface_Addres, // IP address of the interface where the data is expected
IPAddress Multicast_Address, // Multicast address of the expected data
int PortNumber,
IPAddress Frwd_Interface_Addres, // IP address of the forward interface
IPAddress Frwd_Multicast_Address, // Multicast address of the forwarded data
int Frwd_PortNumber)
{
// Open up outgoing socket
// Open up a new socket with the net IP address and port number
try
{
tx_sock = new UdpClient();
tx_sock.JoinMulticastGroup(Frwd_Multicast_Address, Frwd_Interface_Addres);
tx_iep = new IPEndPoint(Frwd_Multicast_Address, Frwd_PortNumber);
}
catch
{
MessageBox.Show("Not possible! Make sure given IP address/port is a valid one on your system or not already used by some other process");
return false;
}
// Check if recording is already in place, if so then
// do not create a new incoming connection
if (IsConnectionActive() == false)
{
// Open up a new socket with the net IP address and port number
try
{
rcv_sock = new UdpClient(PortNumber);
rcv_sock.JoinMulticastGroup(Multicast_Address, Interface_Addres);
rcv_iep = new IPEndPoint(IPAddress.Any, PortNumber);
}
catch
{
MessageBox.Show("Not possible! Make sure given IP address/port is a valid one on your system or not already used by some other process");
return false;
}
KeepGoing = true;
RequestStop = false;
ListenForDataThread = new Thread(new ThreadStart(DOWork));
ListenForDataThread.Start();
}
ForwardingEnabled = true;
return true;
}
private void checkBoxF5_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxF5.Checked == true) { if (RecForwConnection5.StartForward( //Source parameters (always passed in, however the connection manager will use it just in the case the // connection is not active already) IPAddress.Parse(this.listBoxLocalAddr.Items[4].ToString()), IPAddress.Parse(this.listBoxIPAddress.Items[4].ToString()), int.Parse(this.listBoxPort.Items[4].ToString()), // Forward parameters IPAddress.Parse(this.listBoxForwardingInterface.Items[4].ToString()), IPAddress.Parse(this.listBoxForwardingMulticast.Items[4].ToString()), int.Parse(this.listBoxForwardingPort.Items[4].ToString())) == false) { this.checkBoxF5.Checked = false; } else { this.progressBarF5.Visible = true; } } else { RecForwConnection5.StopForwarding(); this.progressBarF5.Visible = false; } }