This just tries to determine if the server will honor
 requests as specified above so that the TCPServer initializer
 can error out early if it won't.
426434
def verify()
      send_bridge_request()
      begin
        line = gets()
        match = line.match(%r{^HTTP/1\.[01] ([0-9]{3,3}) (.*)$})
        if (!match)
          raise "HTTP BRIDGE error: bridge server sent incorrect reply to bridge request."
        end
        case code = match[1].to_i
        when 100, 101
          return true
  			when 401 # 401 Access Denied, key wasn't right.
  			  raise "HTTP BRIDGE error #{code}: host key was invalid or missing, but required."
  		  when 503, 504 # 503 Service Unavailable or 504 Gateway Timeout
  		    raise "HTTP BRIDGE error #{code}: could not verify server can handle requests because it's overloaded."
  	    else
  	      raise "HTTP BRIDGE error #{code}: #{match[2]} unknown error connecting to bridge server."
        end 
      ensure
        close() # once we do this, we just assume the connection is useless.
      end
    end
161911
def serve_forever(self, poll_interval=0.5):
        
        self._serving_event.set()
        self._shutdown_request_event.clear()
        TCPServer.serve_forever(self, poll_interval=poll_interval)
660398
function(err){
  //if this is already a network error just throw it
  if(err instanceof NetworkError){
    throw err
  }
  //convert strings to errors
  if('string' === typeof err){
    err = new Error(err)
  }
  //check if the error message matches a known TCP error
  var error
  for(var i = 0; i < tcpErrors.length; i++){
    if(err.message.indexOf(tcpErrors[i]) >= 0){
      //lets throw a NetworkError
      error = new NetworkError(err.message)
      //preserve the original stack trace so we can actually debug these
      error.stack = err.stack
      throw error
    }
  }
  //if we make it here it is not an error we can handle just throw it
  throw err
}
876013
public boolean isServerStopping() {

        String thisMethodName = CLASS_NAME + ".isServerStopping()";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, thisMethodName, this);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName, new Boolean(_serverStopping));
        }

        return _serverStopping;
    }
222034
public void initialize() throws IOException, NotInitializedException {
    logger.debug("Initialising TCPTransportClient. Origin address is [{}] and destination address is [{}]", origAddress, destAddress);
    if (destAddress == null) {
      throw new NotInitializedException("Destination address is not set");
    }
    socketChannel = SelectorProvider.provider().openSocketChannel();

    try {
      if (origAddress != null) {
        socketChannel.socket().bind(origAddress);
      }

      socketChannel.connect(destAddress);
      //PCB added logging
      socketChannel.configureBlocking(BLOCKING_IO);
      getParent().onConnected();
    }
    catch (IOException e) {
      if (origAddress != null) {
        socketChannel.socket().close();
      }
      socketChannel.close();
      throw e;
    }
  }
801814
private void attemptSocketBind(InetSocketAddress address, boolean reuseflag) throws IOException {
        this.serverSocket.setReuseAddress(reuseflag);
        this.serverSocket.bind(address, this.tcpChannel.getConfig().getListenBacklog());
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "ServerSocket bind worked, reuse=" + this.serverSocket.getReuseAddress());
        }
    }
957878
private boolean shouldOmitPortInHostHeader(HttpUrl url) {
    return (url.scheme().equals("http") && url.port() == 80)
      || (url.scheme().equals("https") && url.port() == 443);
  }
24489
def ensure_started(self):
        
        # server is either starting or stopping (or error)
        if self.state in ['maintenance', 'error']:
            self._wait_for_state_change(['stopped', 'started'])

        if self.state == 'stopped':
            self.start()
            self._wait_for_state_change(['started'])

        if self.state == 'started':
            return True
        else:
            # something went wrong, fail explicitly
            raise Exception('unknown server state: ' + self.state)
465234
public static boolean checkHasNextSafely(Iterator iterator) {
        try {
            /* Throw a ServiceConfigurationError if a provider-configuration file violates the specified format,
            or if it names a provider class that cannot be found and instantiated, or if the result of
            instantiating the class is not assignable to the service type, or if any other kind of exception
            or error is thrown as the next provider is located and instantiated.
            @see http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html#iterator()
            */
            return iterator.hasNext();
        } catch (Exception | ServiceConfigurationError e) {
            LOGGER.trace("Can't load some service using Java SPI", e);
            LOGGER.error(e.getMessage());
            return false;
        }
    }
556584
@FFDCIgnore(Exception.class)
    private void checkVCAPHost(ServerInfo server) {
        String VCAP_APPLICATION = System.getenv("VCAP_APPLICATION");
        if (VCAP_APPLICATION != null) {
            try {
                JsonNode node = Json.mapper().readValue(VCAP_APPLICATION, JsonNode.class);
                ArrayNode uris = (ArrayNode) node.get("uris");
                if (uris != null && uris.size() > 0 && uris.get(0) != null) {
                    server.setHost(uris.get(0).textValue());
                    if (OpenAPIUtils.isEventEnabled(tc)) {
                        Tr.event(this, tc, "Changed hostPort using VCAP_APPLICATION.  New value: " + server.getHost());
                    }
                }
            } catch (Exception e) {
                if (OpenAPIUtils.isEventEnabled(tc)) {
                    Tr.event(this, tc, "Exception while parsing VCAP_APPLICATION env: " + e.getMessage());
                }
            }
        }
    }
689887
def start(self, tcpport=102):
        
        if tcpport != 102:
            logger.info("setting server TCP port to %s" % tcpport)
            self.set_param(snap7.snap7types.LocalPort, tcpport)
        logger.info("starting server on 0.0.0.0:%s" % tcpport)
        return self.library.Srv_Start(self.pointer)
909773
private void serverHelloRequest(HelloRequest mesg) throws IOException {
        if (debug != null && Debug.isOn("handshake")) {
            mesg.print(System.out);
        }

        //
        // Could be (e.g. at connection setup) that we already
        // sent the "client hello" but the server's not seen it.
        //
        if (state < HandshakeMessage.ht_client_hello) {
            if (!secureRenegotiation && !allowUnsafeRenegotiation) {
                // renegotiation is not allowed.
                if (activeProtocolVersion.v >= ProtocolVersion.TLS10.v) {
                    // response with a no_renegotiation warning,
                    warningSE(Alerts.alert_no_renegotiation);

                    // invalidate the handshake so that the caller can
                    // dispose this object.
                    invalidated = true;

                    // If there is still unread block in the handshake
                    // input stream, it would be truncated with the disposal
                    // and the next handshake message will become incomplete.
                    //
                    // However, according to SSL/TLS specifications, no more
                    // handshake message should immediately follow ClientHello
                    // or HelloRequest. So just let it be.
                } else {
                    // For SSLv3, send the handshake_failure fatal error.
                    // Note that SSLv3 does not define a no_renegotiation
                    // alert like TLSv1. However we cannot ignore the message
                    // simply, otherwise the other side was waiting for a
                    // response that would never come.
                    fatalSE(Alerts.alert_handshake_failure,
                        "Renegotiation is not allowed");
                }
            } else {
                if (!secureRenegotiation) {
                    if (debug != null && Debug.isOn("handshake")) {
                        System.out.println(
                            "Warning: continue with insecure renegotiation");
                    }
                }
                kickstart();
            }
        }
    }
787196
@Override
  public int acceptInitialRead(byte []buffer, int offset, int length)
    throws IOException
  {
    Socket socket = getSocket();

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

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

    return socket.getInputStream().read(buffer, offset, length);
  }
807197
def _EnsureRequesterStarted(self):
    """"""
    if not self._analyzer_started:
      self._analyzer.start()
      self._analyzer_started = True
96932
public boolean isAccepted(IRequestInfo req) {
        boolean answer = true;
        if (processAll) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "processAll is true, therefore we always intercept.");
            }
            return answer;
        }

        String HTTPheader = null;

        Iterator<ICondition> iter = filterCondition.iterator();
        while (iter.hasNext()) {
            ICondition cond = iter.next();
            String key = cond.getKey();

            // Start with request header attribute name
            HTTPheader = req.getHeader(key);

            boolean ipAddress = false;

            // The header argument is a null, so go through other tags.
            if (HTTPheader == null) {
                if (key.equals(REMOTE_ADDRESS)) {
                    HTTPheader = req.getRemoteAddr();
                    ipAddress = true;
                } else if (key.equals(REQUEST_URL)) {
                    HTTPheader = req.getRequestURL();
                } else if (key.equals(AuthFilterConfig.KEY_WEB_APP) || key.equals(APPLICATION_NAMES)) {
                    HTTPheader = req.getApplicationName();
                } else if (key.equals(AuthFilterConfig.KEY_COOKIE)) {
                    HTTPheader = req.getCookieName(key);
                } else if (cond instanceof NotContainsCondition) {
                    continue;
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "No HTTPheader found, and no remote-address, request-url, webApp, applicationNames, cookie, or requestHeader rule used - do not Intercept.");
                    }
                    return false; // if no header found, the condition fails
                }
            }
            if (HTTPheader == null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "No HTTPheader found - do not Intercept.");
                }
                return false; // if no header found, the condition fails
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Checking condition {0} {1}.", new Object[] { cond, HTTPheader });
            }
            try {
                IValue compareValue;
                if (ipAddress) {
                    compareValue = new ValueIPAddress(HTTPheader);
                } else {
                    compareValue = new ValueString(HTTPheader);
                }
                answer = cond.checkCondition(compareValue);
                if (!answer) {
                    break;
                }

            } catch (FilterException e) {
                throw new RuntimeException(e);
            }
        }
        return answer;
    }
129091
static void checkDoublesSerVer(final int serVer, final int minSupportedSerVer) {
    final int max = DoublesSketch.DOUBLES_SER_VER;
    if ((serVer > max) || (serVer < minSupportedSerVer)) {
      throw new SketchesArgumentException(
          "Possible corruption: Unsupported Serialization Version: " + serVer);
    }
  }
721579
protected function guardServerStarting()
    {
        if ($socket = @fsockopen($this->host, $this->port, $errorNumber = 0, $errorString = '', $timeout = 1)) {
            fclose($socket);
            throw new UnableToStartServer($this->host.':'.$this->port);
        }
    }