BACnet.IP.UDPAsyncServer.Send C# (CSharp) Метод

Send() публичный Метод

Sends a datagram
public Send ( IPEndPoint ep, byte buffer, int length ) : void
ep System.Net.IPEndPoint The IPEndPoint of the destination device
buffer byte The buffer containing the datagram to send
length int The length of the datagram to send
Результат void
        public void Send(IPEndPoint ep, byte[] buffer, int length)
        {
            lock(_lock)
            {
                _socket.BeginSendTo(buffer, 0, length, SocketFlags.None, ep, _sendCallback, null);
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Sends a bvlc message
        /// </summary>
        /// <param name="mac">The BACnet mac address of the destination device</param>
        /// <param name="message"></param>
        private void _sendMessage(Mac mac, IBvlcMessage message)
        {
            // TODO: constant for buffer size, or
            // lease buffers from the UDPAsyncServer instance
            IPEndPoint ep = IPUtils.MacToIPEndPoint(mac);

            byte[]     buffer = new byte[1500];
            int        offset = 0;
            BvlcHeader header = null;


            header          = new BvlcHeader();
            header.Function = message.Function;
            header.Length   = 0;
            offset          = header.Serialize(buffer, offset);
            offset          = message.Serialize(buffer, offset);

            // patch the length in now that it is known
            buffer[2] = (byte)(offset << 8);
            buffer[3] = (byte)(offset);

            _server.Send(ep, buffer, offset);
        }