2015年11月29日 星期日

TCP test

<script>
var mySocket = null;

function openTCP() {
    mySocket = new navigator.TCPSocket("www.tsvs.ntpc.edu.tw", 80);
    if (mySocket.opened) {
        console.log("TCP connection established sucessfully");
        mySocket.writeable.write("Hello World");
    } else {
       console.log("TCP connection established fail");
    };
};

function closeTCP() {
    mySocket.halfClose();
    mySocket.close();
    if (mySocket.closed) {
      console.log("TCP socket has been cleanly closed");
    };
};

</script>


<a class="v001" href="#" >櫻樹 變 櫻花</a>
<br>
<button type="button" onclick="openTCP()">TCP Open</button>
<button type="button" onclick="closeTCP()">TCP Close</button>

沒有留言:

張貼留言