コード例 #1
0
        /// <summary>
        /// This function established  the connection for the channel in passive (server) mode. This function waits for the request from the peer.
        /// </summary>
        public bool Listen()
        {
            byte s = _scoket_number;

            if (W5100.IINCHIP_READ(s, W5100.SocketRegisters.SR) == (byte)SR_val.SOCK_INIT)
            {
                W5100.IINCHIP_WRITE(s, W5100.SocketRegisters.CR, (byte)CR_val.Sn_CR_LISTEN);
                /* +20071122[chungs]:wait to process the command... */
                while (W5100.IINCHIP_READ(s, W5100.SocketRegisters.CR) != 0)
                {
                    ;
                }
                /* ------- */
                return(true);
            }
            else
            {
                return(false);
                //new Exception("Fail[invalid ip,port]\r\n");
            }
        }
コード例 #2
0
        /// <summary>
        /// This function close the socket
        /// </summary>
        public void Close()
        {
            byte s = _scoket_number;

            W5100.IINCHIP_WRITE(s, W5100.SocketRegisters.CR, (byte)CR_val.Sn_CR_CLOSE);

            /* +20071122[chungs]:wait to process the command... */
            while (W5100.IINCHIP_READ(s, W5100.SocketRegisters.CR) != 0)
            {
                ;
            }
            /* ------- */

            /* +2008.01 [hwkim]: clear interrupt */
            //#ifdef __DEF_IINCHIP_INT__
            /* m2008.01 [bj] : all clear */
            //     putISR(s, 0x00);
            //#else
            /* m2008.01 [bj] : all clear */
            W5100.IINCHIP_WRITE(s, W5100.SocketRegisters.IR, 0xFF);
            //#endif
            _scoket_number = 100;
            Socket[s]      = false;
        }