<commit_before># websocket
High quality low grade server side WebSocket (RFC 6455) implementation.

## Motivation
Web requests are typically follow a request-response pattern. The client
communicates the resource that it wants, and the server responds with the
content that resource (or an error status code). After this the connection
between client and server is closed and communication ends.

WebSocket (RFC 6455) allows an HTTP client, such as a modern web browser, to
request that the HTTP connection not close, but rather be upgraded to a
communication channel for an on-going two-way exchange of binary and text data.
Basically, the client says: Don't hang up yet, let's chat awhile.

This fills an interesting niche in client-server communications. At first,
it looks and acts (and actually, is) a web (HTTP) request. This allows the
communication to get around most networking/firewall problems involved with
opening a direct communication channel. Yet, after the WebSocket handshake,
the channel acts very much like a traditional socket. The connection stays
open and any data may be put on the wire.

## websocket
This component is a server-side WebSocket implementation. By using the
provided WebSocketServerSocket to decorate a ServerSocket, the server can
listen for WebSocket connections and treat them like a traditional socket.

WebSocketServerSocket itself is a ServerSocket. So, it can be used anywhere
in your application that a ServerSocket might be used. WebSocketServerSocket
can decorate any ServerSocket, including SSLServerSocket, if you want to
support secure WebSocket connections.

## Usage
This is how you start listening for WebSocket connections:

    ServerSocket serverSocket = new ServerSocket(PORT);
    WebSocketServerSocket webSocketServerSocket = new WebSocketServerSocket(serverSocket);
    WebSocket webSocket = webSocketServerSocket.accept();

And this is how you read data from the connecting client:

    InputStream is = webSocket.getInputStream();
    int data = is.read();

And this is how you communicate back to the connecting client:

    WebSocketServerOutputStream os = webSocket.getOutputStream();
    os.writeString("This is a UTF-8 string.");
    os.writeBinary("Some binary data.".getBytes());

Note that this usage is as raw as it gets, giving you the bytes sent over
the WebSocket.

### Echo server example
Included in this component is the example EchoServer. By running this, you
can test the WebSocket implementation.

    mvn install
    ./start-echo-server

Then point your browser to the following URL:

    (http://www.websocket.org/echo.html)[http://www.websocket.org/echo.html]

Change the server to:

    localhost:8080

You can then test that the server is echoing back the bytes that it has
received.

## Features
This WebSocket implementation is safe for very large frames. It does NOT
allocate large buffers in anticipation of large frames.

The code is:<commit_msg>Documentation update<commit_after># websocket
High quality low grade server side WebSocket (RFC 6455) implementation.

## Motivation
Web requests are typically follow a request-response pattern. The client
communicates the resource that it wants, and the server responds with the
content that resource (or an error status code). After this the connection
between client and server is closed and communication ends.

WebSocket (RFC 6455) allows an HTTP client, such as a modern web browser, to
request that the HTTP connection not close, but rather be upgraded to a
communication channel for an on-going two-way exchange of binary and text data.
Basically, the client says: Don't hang up yet, let's chat awhile.

This fills an interesting niche in client-server communications. At first,
it looks and acts (and actually, is) a web (HTTP) request. This allows the
communication to get around most networking/firewall problems involved with
opening a direct communication channel. Yet, after the WebSocket handshake,
the channel acts very much like a traditional socket. The connection stays
open and any data may be put on the wire.

## websocket
This component is a server-side WebSocket implementation. By using the
provided WebSocketServerSocket to decorate a ServerSocket, the server can
listen for WebSocket connections and treat them like a traditional socket.

WebSocketServerSocket itself is a ServerSocket. So, it can be used anywhere
in your application that a ServerSocket might be used. WebSocketServerSocket
can decorate any ServerSocket, including SSLServerSocket, if you want to
support secure WebSocket connections.

## Usage
This is how you start listening for WebSocket connections:

    ServerSocket serverSocket = new ServerSocket(PORT);
    WebSocketServerSocket webSocketServerSocket = new WebSocketServerSocket(serverSocket);
    WebSocket webSocket = webSocketServerSocket.accept();

And this is how you read data from the connecting client:

    InputStream is = webSocket.getInputStream();
    int data = is.read();

And this is how you communicate back to the connecting client:

    WebSocketServerOutputStream os = webSocket.getOutputStream();
    os.writeString("This is a UTF-8 string.");
    os.writeBinary("Some binary data.".getBytes());

Note that this usage is as raw as it gets, giving you the bytes sent over
the WebSocket.

### Echo server example
Included in this component is the example EchoServer. By running this, you
can test the WebSocket implementation.

    mvn install
    ./start-echo-server

Then point your browser to the following URL:

* [http://www.websocket.org/echo.html](http://www.websocket.org/echo.html)

Change the server to:

    localhost:8080

You can then test that the server is echoing back the bytes that it has
received.

## Features
This WebSocket implementation is safe for very large frames. It does NOT
allocate large buffers in anticipation of large frames.

The code is:
{'fraction_non_alphanumeric': 0.05014448410674826, 'fraction_numerical': 0.004419513853476118, 'mean_word_length': 4.609151572926597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1706063', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1391, 'n_words': 784}