Attaches a websocket server to the specified http server.
6423
function (server) {

      // Retrieve the configured handler.
      if (handler) {
        handler = require(require('path').resolve() + '/' + handler);
      } else {
        console.log('No handler defined for websocket server, not starting websocket.');
        return;
      }

      // Attach websockets server to http server
      var WebSocketServer = require('websocket').server;
      var wsServer = new WebSocketServer({
        httpServer: server
      });

      // Handle requests
      wsServer.on('request', handler);
    }
362146
public void connect() throws IOException, DeploymentException {
        WebSocketContainer container = ContainerProvider.getWebSocketContainer();
        container.connectToServer(this, wssUri);
        log.debug("client connected to the server: {}", wssUri);
    }
393906
def send_to_websocket(self, data):
        """"""
        data = json.dumps(data)
        self.websocket.send(data)
104464
async def _connect_websocket(self, url, headers, engineio_path):
        """"""
        if websockets is None:  # pragma: no cover
            self.logger.error('websockets package not installed')
            return False
        websocket_url = self._get_engineio_url(url, engineio_path,
                                               'websocket')
        if self.sid:
            self.logger.info(
                'Attempting WebSocket upgrade to ' + websocket_url)
            upgrade = True
            websocket_url += '&sid=' + self.sid
        else:
            upgrade = False
            self.base_url = websocket_url
            self.logger.info(
                'Attempting WebSocket connection to ' + websocket_url)

        # get the cookies from the long-polling connection so that they can
        # also be sent the the WebSocket route
        cookies = None
        if self.http:
            cookies = '; '.join(["{}={}".format(cookie.key, cookie.value)
                                 for cookie in self.http._cookie_jar])
            headers = headers.copy()
            headers['Cookie'] = cookies

        try:
            ws = await websockets.connect(
                websocket_url + self._get_url_timestamp(),
                extra_headers=headers)
        except (websockets.exceptions.InvalidURI,
                websockets.exceptions.InvalidHandshake):
            if upgrade:
                self.logger.warning(
                    'WebSocket upgrade failed: connection error')
                return False
            else:
                raise exceptions.ConnectionError('Connection error')
        if upgrade:
            p = packet.Packet(packet.PING, data='probe').encode(
                always_bytes=False)
            try:
                await ws.send(p)
            except Exception as e:  # pragma: no cover
                self.logger.warning(
                    'WebSocket upgrade failed: unexpected send exception: %s',
                    str(e))
                return False
            try:
                p = await ws.recv()
            except Exception as e:  # pragma: no cover
                self.logger.warning(
                    'WebSocket upgrade failed: unexpected recv exception: %s',
                    str(e))
                return False
            pkt = packet.Packet(encoded_packet=p)
            if pkt.packet_type != packet.PONG or pkt.data != 'probe':
                self.logger.warning(
                    'WebSocket upgrade failed: no PONG packet')
                return False
            p = packet.Packet(packet.UPGRADE).encode(always_bytes=False)
            try:
                await ws.send(p)
            except Exception as e:  # pragma: no cover
                self.logger.warning(
                    'WebSocket upgrade failed: unexpected send exception: %s',
                    str(e))
                return False
            self.current_transport = 'websocket'
            if self.http:  # pragma: no cover
                await self.http.close()
            self.logger.info('WebSocket upgrade was successful')
        else:
            try:
                p = await ws.recv()
            except Exception as e:  # pragma: no cover
                raise exceptions.ConnectionError(
                    'Unexpected recv exception: ' + str(e))
            open_packet = packet.Packet(encoded_packet=p)
            if open_packet.packet_type != packet.OPEN:
                raise exceptions.ConnectionError('no OPEN packet')
            self.logger.info(
                'WebSocket connection accepted with ' + str(open_packet.data))
            self.sid = open_packet.data['sid']
            self.upgrades = open_packet.data['upgrades']
            self.ping_interval = open_packet.data['pingInterval'] / 1000.0
            self.ping_timeout = open_packet.data['pingTimeout'] / 1000.0
            self.current_transport = 'websocket'

            self.state = 'connected'
            client.connected_clients.append(self)
            await self._trigger_event('connect', run_async=False)

        self.ws = ws
        self.ping_loop_task = self.start_background_task(self._ping_loop)
        self.write_loop_task = self.start_background_task(self._write_loop)
        self.read_loop_task = self.start_background_task(
            self._read_loop_websocket)
        return True
537061
def set_server(self, server_pos, key, value):
        """"""
        if zeroconf_tag and self.zeroconf_enable_tag:
            self.listener.set_server(server_pos, key, value)
1107809
function WebServer(data) {
  // Use a closure to preserve `this`
  var self = this;
  self.data = data;

  this.RequestHandler = bind(this.RequestHandler, this);
  this.callbackExecutor = bind(this.callbackExecutor, this);

  self.server = http.createServer(self.RequestHandler);

  // Use random port if port settings is not provided.
  if (!self.data.port) {
    self.data.port = 0;
  }

  // Use address if provided.
  if (self.data.hostname) {
    self.server.listen(self.data.port, self.data.hostname);
  } else {
    self.server.listen(self.data.port);
  }

  self.server.on('listening', function() {
    self.debug.log('Listen on :%s', self.server.address().port);
  });
}
1280811
function attachRoutes(router, routes = [], site) {
  routes.forEach((route) => {
    parseHandler(router, route, site);
  });

  return router;
}
524720
public static WebsocketServerTransport create(String bindAddress, int port) {
    Objects.requireNonNull(bindAddress, "bindAddress must not be null");

    HttpServer httpServer = HttpServer.create().host(bindAddress).port(port);
    return create(httpServer);
  }
1184505
async def open_websocket(url: str,
                         headers: Optional[list] = None,
                         subprotocols: Optional[list] = None):
    
    ws = await create_websocket(
        url, headers=headers, subprotocols=subprotocols)
    try:
        yield ws
    finally:
        await ws.close()
926853
def server_bind(self):
        

        if self.allow_reuse_address:
            self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.socket.bind(self.server_address)
972570
def serve(self, host='127.0.0.1', port=5000):
        """"""
        from meinheld import server, middleware
        # self.app.run(host=host, port=port)
        server.listen((host, port))
        server.run(middleware.WebSocketMiddleware(self.app))
844857
function WebsocketRouter(options) {
  options = options || {};
  this.clientsPath = [];
  this.host = options.host ? options.host : 'localhost';
  this.port = options.port ? options.port : 8000;
}
758253
public JwwfServer attachPlugin(JwwfPlugin plugin) {
		plugins.add(plugin);
		if (plugin instanceof IPluginGlobal)
			((IPluginGlobal) plugin).onAttach(this);
		return this;
	}
1348190
def attach(gandi, name, vhost, remote):
    
    return gandi.paas.attach(name, vhost, remote)
1344189
@Override
    public Server addServer(String serverName, String hostAddress, int port) throws Exception {
        return addServer(serverName, hostAddress, port, IpChannelType.SCTP, false, 0, null);
    }
601083
def addServer(self, normalPort, sslPort, f, name):
        
        tcp = internet.TCPServer(normalPort, f)
        tcp.setName(name)
        self.servers.append(tcp)
        if sslPort is not None:
            ssl = internet.SSLServer(sslPort, f, contextFactory=self.sslfac)
            ssl.setName(name+'s')
            self.servers.append(ssl)
289064
def connectToServer(self):
    """"""
    self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
      self.rtspSocket.connect((self.serverAddr, self.serverPort))
    except:
      tkinter.messagebox.showwarning('Connection Failed', 'Connection to \'%s\' failed.' %self.serverAddr)