



9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
B~wNode.jsӰwebsocket (OϥPHPتwebsocket)9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
²¦Gǥ IE (10+) ]clientݨӶǥXr(޳ۿ˴Gwindows & Ubuntu]serverݡAiǥchromeާ@\BIE11,MyIEާ@)9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
U 06:15 2025/12/9
****
סG
椸ȴѳ²ClientݶǥXrᥴLW
ServerݦwNode.jsӰwebsocket (OϥPHPتwebsocket)Awindows & Ubuntu]server
clientݥiǥchromeާ@\BIE11,MyIEާ@

****
websocketNode.jsserverݡBclientݹթIEMyIEsB@CGoogleqG
https://www.google.com/search?q=websocket+server+javascript+work+in+IE+example&oq=websocket+server+javascript+work+in+IE+example&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQABjvBTIHCAIQABjvBTIHCAMQABjvBdIBCDM2NjFqMGo0qAIAsAIB&sourceid=chrome&ie=UTF-8
https://cc.ee.ntu.edu.tw/~d01941025/zz_code_ie10WebSocketServerNodejsA.png
https://cc.ee.ntu.edu.tw/~d01941025/zz_code_ie10WebSocketServerNodejsB.png
https://cc.ee.ntu.edu.tw/~d01941025/zz_code_ie10WebSocketServerNodejsC.png
https://cc.ee.ntu.edu.tw/~d01941025/zz_code_ie10WebSocketServerNodejsD.png

****
U{ɮסG
https://cc.ee.ntu.edu.tw/~d01941025/zz_code_ie10WebSocketServerNodejs.zip
ާ@vG
https://cc.ee.ntu.edu.tw/~d01941025/zz_code_ie10WebSocketServerNodejs.mp4

****
windowstκ޲zCMDBlinuxterminalG
cmdUCG
cd ܵ{|AĴpG
cd C:\Apache24\htdocswillya\AAAAAAA\2025.11.26\zz_code_ie10WebSocketServerNodejs
^windowsq
cd /var/www/html/ie
ubuntuq

cmdUCG
npm init

cmdUCG
npm install ws

i{ҦbƧͦ\hHɡAĴpG
node_modules(Ƨ)
package.json
package-lock.json

9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9
9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9
KJϵ{XAæsɡAɦWGserver.js<~媩
9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9
9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9
9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9

const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 }); // Create a WebSocket server on port 8080

wss.on('connection', ws => {
    console.log('Client connected');

    // Listen for messages from the client
    ws.on('message', message => {
        console.log(`Received message: ${message}`);
        // Echo the message back to the client
        ws.send(`Server received: ${message}`);
    });

    // Handle the client closing the connection
    ws.on('close', () => {
        console.log('Client disconnected');
    });
    
    // Handle errors
    ws.on('error', error => {
        console.error('WebSocket error:', error);
    });
});

console.log('Web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9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9-9
9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9=9

<!DOCTYPE html>
<html>
<head>
    <title>WebSocket IE Example</title>
</head>
<body>
    <h1>WebSocket Example (IE 10+)</h1>
    <input type="text" id="messageInput" placeholder="Enter message">
    <button onclick="sendMessage()">Send</button>
    <div id="messages"></div>

    <script>
        // Use "ws://" for local development, "wss://" for production (over HTTPS)
        const socket = new WebSocket('ws://localhost:8080');
        const messagesEl = document.getElementById('messages');

        // Connection opened event
        socket.onopen = function(event) {
            messagesEl.innerHTML += '<p style="color: green;">Connection established.</p>';
        };

        // Listen for messages from the server
        socket.onmessage = function(event) {
            messagesEl.innerHTML += `<p>Server: ${event.data}</p>`;
            console.log("Message from server ", event.data);
        };

        // Handle errors
        socket.onerror = function(error) {
            messagesEl.innerHTML += `<p style="color: red;">Error: ${error.message}</p>`;
        };

        // Connection closed event
        socket.onclose = function(event) {
            messagesEl.innerHTML += '<p style="color: grey;">Connection closed.</p>';
        };

        function sendMessage() {
            const input = document.getElementById('messageInput');
            const message = input.value;
            if (socket.readyState === WebSocket.OPEN) {
                socket.send(message); // Send the message to the server
                messagesEl.innerHTML += `<p>Client: ${message}</p>`;
                input.value = '';
            } else {
                messagesEl.innerHTML += '<p style="color: orange;">Connection not open.</p>';
            }
        }
    </script>
</body>
</html>


6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6
6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6
KJϵ{XAæsɡAɦWGclient.html<~媩
6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6
6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6-6
6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6=6

********
ServerݬObWindowsUiާ@G
****
}chromesAsG
http://127.0.0.1:8888/AAAAAAA/2025.11.26/zz_code_ie10WebSocketServerNodejs/client.html
ؤJrAASendAiLXҶǥXrC

****
}ie11,MyIEsAsG
http://127.0.0.1:8888/AAAAAAA/2025.11.26/zz_code_ie10WebSocketServerNodejs/client.html
ؤJrAASendALkLXҶǥXrC
^]ie11,MyIE楢
----------------------------------------------------------------------------------------------

********
ServerݬObUbuntu18.04Uiާ@G
****
}chromesAsG
http://192.168.3.105/ie/clientB.html
ؤJrAASendAiLXҶǥXrC

****
}ie11,MyIEsAsG
http://192.168.3.105/ie/clientB.html
ؤJrAASendALkLXҶǥXrC
^]ie11,MyIE楢


6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
B~wNode.jsӰwebsocket (OϥPHPتwebsocket)6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
²¦Gǥ IE (10+) ]clientݨӶǥXr(޳ۿ˴Gwindows & Ubuntu]serverݡAiǥchromeާ@\BIE11,MyIEާ@)6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
