예제 #1
0
파일: COTP.cs 프로젝트: zsonem60/s7netplus
            /// <summary>
            /// Reads COTP TPDU (Transport protocol data unit) from the network stream
            /// See: https://tools.ietf.org/html/rfc905
            /// </summary>
            /// <param name="stream">The socket to read from</param>
            /// <returns>COTP DPDU instance</returns>
            public static TPDU Read(Stream stream)
            {
                var tpkt = TPKT.Read(stream);

                if (tpkt.Length > 0)
                {
                    return(new TPDU(tpkt));
                }
                return(null);
            }
예제 #2
0
            /// <summary>
            /// Reads COTP TPDU (Transport protocol data unit) from the network stream
            /// See: https://tools.ietf.org/html/rfc905
            /// </summary>
            /// <param name="socket">The socket to read from</param>
            /// <returns>COTP DPDU instance</returns>
            public static TPDU Read(Socket socket)
            {
                var tpkt = TPKT.Read(socket);

                if (tpkt.Length > 0)
                {
                    return(new TPDU(tpkt));
                }
                return(null);
            }
예제 #3
0
            /// <summary>
            /// Reads COTP TPDU (Transport protocol data unit) from the network stream
            /// See: https://tools.ietf.org/html/rfc905
            /// </summary>
            /// <param name="stream">The socket to read from</param>
            /// <returns>COTP DPDU instance</returns>
            public static TPDU Read(Stream stream)
            {
                var tpkt = TPKT.Read(stream);

                if (tpkt.Length == 0)
                {
                    throw new TPDUInvalidException("No protocol data received");
                }
                return(new TPDU(tpkt));
            }