Sends a complete pong message using blocking IO
Automatically frees the pooled byte buffer when done.

@param pooledData The data to send, it will be freed when done
@param wsChannel The web socket channel
761599
public static void sendPongBlocking(final PooledByteBuffer pooledData, final WebSocketChannel wsChannel) throws IOException {
        sendBlockingInternal(pooledData, WebSocketFrameType.PONG, wsChannel);
    }
585910
public static void sendClose(final CloseMessage closeMessage, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) {
        sendClose(closeMessage, wsChannel, callback, null);
    }
1050590
function ws_send(socket, data) {
	//console.log("send: " + data);
	let header;
	let payload = new Buffer.from(data);
	const len = payload.length;
	
	if (len <= 125) {
		header = new Buffer.alloc(2);
		header[1] = len;
	} else if (len <= 0xffff) {
		header = new Buffer.alloc(4);
		header[1] = 126;
		header[2] = (len >> 8) & 0xff;
		header[3] = len & 0xff;
	} else { /* 0xffff < len <= 2^63 */
		header = new Buffer(10);
		header[1] = 127;
		header[2] = (len >> 56) & 0xff;
		header[3] = (len >> 48) & 0xff;
		header[4] = (len >> 40) & 0xff;
		header[5] = (len >> 32) & 0xff;
		header[6] = (len >> 24) & 0xff;
		header[7] = (len >> 16) & 0xff;
		header[8] = (len >> 8) & 0xff;
		header[9] = len & 0xff;
	}
	
	header[0] = 0x81;
	socket.write(Buffer.concat([header, payload],
		 header.length + payload.length), 'binary');
	//console.log('sent ' + data.length + ' bytes');
}
769235
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
        if (frame instanceof CloseWebSocketFrame) {
            this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
            CompletableFuture.completedFuture(new WebSocketContext(this.session,this.handler))
                    .thenAcceptAsync(this.handler::onDisConnect);
            return;
        }
        if (frame instanceof PingWebSocketFrame) {
            ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
            return;
        }

        if (!(frame instanceof TextWebSocketFrame)) {
            throw new UnsupportedOperationException("unsupported frame type: " + frame.getClass().getName());
        }
        CompletableFuture.completedFuture(new WebSocketContext(this.session,this.handler,((TextWebSocketFrame) frame).text()))
                .thenAcceptAsync(this.handler::onText,ctx.executor());
    }
1014650
private SslHandshakeResult initializeSocket(SocketChannel sc, boolean clientMode, List<Long> clockSkews)
            throws IOException {
        ByteBuffer timeBuffer = ByteBuffer.allocate(Long.BYTES);
        if (clientMode) {
            synchronized (sc.blockingLock()) {
                boolean isBlocking = sc.isBlocking();
                // Just being lazy and using blocking mode here to get the server's current timestamp
                sc.configureBlocking(true);
                do {
                    sc.read(timeBuffer);
                } while (timeBuffer.hasRemaining());
                sc.configureBlocking(isBlocking);
            }
            if (clockSkews != null) {
                clockSkews.add(System.currentTimeMillis() - ((ByteBuffer) timeBuffer.flip()).getLong());
            }
        } else {
            timeBuffer.putLong(System.currentTimeMillis());
            timeBuffer.flip();
            do {
                sc.write(timeBuffer);
            } while (timeBuffer.hasRemaining());
        }
        return setupSSLIfNeeded(sc, clientMode);
    }
619598
public static void sendBinaryBlocking(final ByteBuffer data, final WebSocketChannel wsChannel) throws IOException {
        sendBlockingInternal(data, WebSocketFrameType.BINARY, wsChannel);
    }
1336600
public static void sendBlockData(Chunk chunk, String identifier, ByteBuf data, EntityPlayerMP player)
	{
		MalisisCore.network.sendTo(new Packet(chunk, identifier, data), player);
	}
52754
public void init(SocketChannel s)
  {
    _s = s;

    try {
      s.setOption(StandardSocketOptions.TCP_NODELAY, true);
    } catch (Exception e) {
      e.printStackTrace();;
    }
    //_is = null;
    //_os = null;
    _needsFlush = false;
    
    _readBuffer.clear().flip();
    _writeBuffer.clear();
  }
729052
function() {
        while (pushSendDataQueue.length > 0 && socketState === socketStateType.OPEN) {
          var msg = pushSendDataQueue.splice(0, 1)[0];
          pushSendData(msg);
        }
      }
864104
public synchronized void send(String data, String event, String id, EventCallback callback) {
        if (open == 0 || shutdown) {
            if (callback != null) {
                callback.failed(this, data, event, id, new ClosedChannelException());
            }
            return;
        }
        queue.add(new SSEData(event, data, id, callback));
        sink.getIoThread().execute(new Runnable() {
            @Override
            public void run() {
                synchronized (ServerSentEventConnection.this) {
                    if (pooled == null) {
                        fillBuffer();
                        writeListener.handleEvent(sink);
                    }
                }
            }
        });
    }
748078
protected void release(ByteArray byteArray) {

    if (byteArray instanceof PooledByteArray) {
      PooledByteArray pooledArray = (PooledByteArray) byteArray;
      if (pooledArray.release()) {
        this.byteArrayPool.release(byteArray.getBytes());
      }
    }
  }
751116
public synchronized void remove(SocketBox sb) {

        int status = ((ManagedSocketBox) sb).getStatus();

        if (!allSockets.containsKey(sb)) {
            throw new IllegalArgumentException("This socket does not seem to exist in the socket pool.");
        }

        allSockets.remove(sb);

        if (status == ManagedSocketBox.FREE) {
            if (!freeSockets.containsKey(sb)) {
                throw new IllegalArgumentException("This socket is marked free, but does not exist in the pool of free sockets.");
            }
            freeSockets.remove(sb);

        } else {
            if (!busySockets.containsKey(sb)) {
                throw new IllegalArgumentException("This socket is marked busy, but does not exist in the pool of busy sockets.");
            }
            busySockets.remove(sb);
        }
    }
821936
public void release(PooledWsByteBufferImpl buffer) {
        if (inUseTable != null) {
            inUseTable.remove(buffer);
        }
        boolean pooled = pool.put(buffer);
        if (isDirectPool && !pooled) {
            destroy(buffer);
        }
    }
75737
public static void sendTextBlocking(final String message, final WebSocketChannel wsChannel) throws IOException {
        final ByteBuffer data = ByteBuffer.wrap(message.getBytes(StandardCharsets.UTF_8));
        sendBlockingInternal(data, WebSocketFrameType.TEXT, wsChannel);
    }
716668
public boolean sendLobbyChatMsg(SteamID steamIDLobby, ByteBuffer data) throws SteamException {

		if (!data.isDirect()) {
			throw new SteamException("Direct buffer required!");
		}

		return sendLobbyChatMsg(pointer, steamIDLobby.handle, data, data.position(), data.remaining());
	}
352607
public boolean accept(SocketBar qSocket)
    throws IOException
  {
    SocketWrapperBar s = (SocketWrapperBar) qSocket;

    Socket socket = _ss.accept();

    if (socket == null)
      return false;

    s.init(socket);

    /*
    // XXX:
    if (isTcpNoDelay())
      socket.setTcpNoDelay(true);
    
    if (isTcpKeepalive())
      socket.setKeepAlive(true);

    if (_connectionSocketTimeout > 0)
      socket.setSoTimeout(_connectionSocketTimeout);

    s.init(socket);
    */

    if (_connectionSocketTimeout > 0) {
      socket.setSoTimeout(_connectionSocketTimeout);
    }
    
    return true;
  }
745241
public void sendSilenceMessage(
    long startStamp,
    long endStamp,
    long completedPrefix,
    boolean requestedOnly,      
    int priority,
    Reliability reliability,
    SIBUuid12 stream)
    throws SIResourceException
  {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "sendSilenceMessage");

    ControlSilence sMsg;
    try
    {
      // Create new Silence message
      sMsg = cmf.createNewControlSilence();
    }
    catch (Exception e)
    {
      // FFDC
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.PtoPOutputHandler.sendSilenceMessage",
        "1:849:1.241",
        this);

      SibTr.exception(tc, e);
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.impl.PtoPOutputHandler",
          "1:856:1.241",
          e });

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "sendSilenceMessage", e);

      throw new SIResourceException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.impl.PtoPOutputHandler",
            "1:867:1.241",
            e },
          null),
        e);
    }

    // As we are using the Guaranteed Header - set all the attributes as
    // well as the ones we want.
    SIMPUtils.setGuaranteedDeliveryProperties(sMsg,
        messageProcessor.getMessagingEngineUuid(), 
        targetMEUuid,
        stream,
        null,
        destinationHandler.getUuid(),
        ProtocolType.UNICASTINPUT,
        GDConfig.PROTOCOL_VERSION);
  
    sMsg.setStartTick(startStamp);
    sMsg.setEndTick(endStamp);
    sMsg.setPriority(priority);
    sMsg.setReliability(reliability);
    sMsg.setCompletedPrefix(completedPrefix);

    // If the destination in a Link add Link specific properties to message
    if( isLink )
    {
      sMsg = (ControlSilence)addLinkProps(sMsg);
    }
    
    // If the destination is system or temporary then  the 
    // routingDestination into th message
    if( this.isSystemOrTemp )
    {
      sMsg.setRoutingDestination(routingDestination); 
    }
 
    // Send message to destination
    // Using MPIO
    // If requestedOnly then this is a response to a Nack so resend at priority+1 
    if( requestedOnly )
      mpio.sendToMe(routingMEUuid, priority+1, sMsg);
    else
      mpio.sendToMe(routingMEUuid, priority, sMsg);
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "sendSilenceMessage");

  }