AsterixDisplayAnalyser.RecForwConnection9.StartRecording C# (CSharp) Метод

StartRecording() публичный статический Метод

public static StartRecording ( bool Is_ReplayFormat, string FilePath, IPAddress Interface_Addres, IPAddress Multicast_Address, int PortNumber ) : bool
Is_ReplayFormat bool
FilePath string
Interface_Addres System.Net.IPAddress
Multicast_Address System.Net.IPAddress
PortNumber int
Результат bool
        public static bool StartRecording(bool Is_ReplayFormat, 
                                          string FilePath,              // Path and file name 
                                          IPAddress Interface_Addres,   // IP address of the interface where the data is expected
                                          IPAddress Multicast_Address,  // Multicast address of the expected data
                                          int PortNumber)
        {
            if (IsConnectionActive() == false)
            {
                // Open up a new socket with the net IP address and port number
                try
                {
                    rcv_sock = new UdpClient();
                    rcv_sock.ExclusiveAddressUse = false;
                    rcv_iep = new IPEndPoint(IPAddress.Any, PortNumber);
                    rcv_sock.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                    rcv_sock.ExclusiveAddressUse = false;
                    rcv_sock.Client.Bind(rcv_iep);
                    rcv_sock.JoinMulticastGroup(Multicast_Address, Interface_Addres);
                }
                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();
            }

            RecordingEnabled = true;
            ReplayFormatRequested = Is_ReplayFormat;
            LastDataBlockDateTime = DateTime.Now;

            // Open up the stream

            try
            {
                RecordingStream = new FileStream(FilePath, FileMode.Create);
                RecordingBinaryWriter = new BinaryWriter(RecordingStream);
            }
            catch
            {

            }

            BytesProcessed = 0;
            return true;
        }