Archive for December, 2009

Test your web browser for Web Socket support

Google announced an improved way for a web application to communicate with a server. The new method is called Web Sockets. You can read more info here on Web Sockets.

Here is a quick test to see if your web browser supports Web Sockets. At the time this post was published Google Chrome developer channel release 4.0.249.0 is the only browser to support Web Sockets.

Here is the JavaScript code (or right click and save file as WebSocketTest.js):

function WebSocketTest()
{
  if ("WebSocket" in window)
  {
    // Google example code
    //  var ws = new WebSocket("ws://example.com/service");
    //  ws.onopen = function()
    //  {
    //    // Web Socket is connected. You can send data by send() method
    //    ws.send("message to send"); ....
    //  };
    //  ws.onmessage = function (evt) { var received_msg = evt.data; ... };
    //  ws.onclose = function() { // websocket is closed. };
    alert("WebSocket supported here!\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\ntest by jimbergman.net (based on Google sample code)");
  }
  else
  {
    // the browser doesn't support WebSocket
    alert("WebSocket NOT supported here!\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\ntest by jimbergman.net (based on Google sample code)");
  }
}

Sample HTML code (save file as WebSocketTest.html in same folder as .js file above):

<html>
<head>
<title>JimBergman.net - JavaScript: WebSocketTest</title>
<script type="text/javascript" src="WebSocketTest.js"></script>
</head>
<body bgcolor="#FFFFFF">
<a href="javascript:WebSocketTest()">Run WebSocket test</a>
</body>
</html>



UPDATE:

Result of this test on an Windows 7 PC in Google Chrome v4.0.249.0


Result of this test on an Windows 7 PC in Mozilla Firefox v3.5.5


Result of this test on an Windows 7 PC in Microsoft Internet Explorer v8.0.7100.0


Result of this test on an Apple iPhone in OS 3.1.2

Valid characters in user names and computer names

The Windows user name cannot contain these characters:
” / \ [ ] : | < > + = ; , ? * %

The Windows computer name cannot contain these characters:
{ | } ~ [ \ ] ^ ‘ : ; < = > ? @ ! ” # $ % ` ( ) + / . , *

The Internet standard computer name only contains these characters:
0-9, a-z, A-Z and – (hyphen)

Computer names also cannot be entirely consist of numbers, and should be 15 characters or fewer.

Wikipedia has a more in-depth technical explanation.