Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
HttpComponents Core Source Code Files
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5.2-src.zip.
You can download httpcomponents-core-5.2-src.zip as described in the previous tutorial and go to the "httpcore5/src" sub-folder to view Source Code files.
You can also browse HttpComponents Core Source Code below:
✍: FYIcenter.com
⏎ org/apache/hc/core5/http/io/SocketConfig.java
/* * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.hc.core5.http.io; import java.net.SocketAddress; import java.util.concurrent.TimeUnit; import org.apache.hc.core5.annotation.Contract; import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; /** * Classic I/O network socket configuration. * * @since 4.3 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class SocketConfig { private static final Timeout DEFAULT_SOCKET_TIMEOUT = Timeout.ofMinutes(3); public static final SocketConfig DEFAULT = new Builder().build(); private final Timeout soTimeout; private final boolean soReuseAddress; private final TimeValue soLinger; private final boolean soKeepAlive; private final boolean tcpNoDelay; private final int sndBufSize; private final int rcvBufSize; private final int backlogSize; private final SocketAddress socksProxyAddress; SocketConfig( final Timeout soTimeout, final boolean soReuseAddress, final TimeValue soLinger, final boolean soKeepAlive, final boolean tcpNoDelay, final int sndBufSize, final int rcvBufSize, final int backlogSize, final SocketAddress socksProxyAddress) { super(); this.soTimeout = soTimeout; this.soReuseAddress = soReuseAddress; this.soLinger = soLinger; this.soKeepAlive = soKeepAlive; this.tcpNoDelay = tcpNoDelay; this.sndBufSize = sndBufSize; this.rcvBufSize = rcvBufSize; this.backlogSize = backlogSize; this.socksProxyAddress = socksProxyAddress; } /** * @see Builder#setSoTimeout(Timeout) */ public Timeout getSoTimeout() { return soTimeout; } /** * @see Builder#setSoReuseAddress(boolean) */ public boolean isSoReuseAddress() { return soReuseAddress; } /** * @see Builder#setSoLinger(TimeValue) */ public TimeValue getSoLinger() { return soLinger; } /** * @see Builder#setSoKeepAlive(boolean) */ public boolean isSoKeepAlive() { return soKeepAlive; } /** * @see Builder#setTcpNoDelay(boolean) */ public boolean isTcpNoDelay() { return tcpNoDelay; } /** * @see Builder#setSndBufSize(int) * @since 4.4 */ public int getSndBufSize() { return sndBufSize; } /** * @see Builder#setRcvBufSize(int) * @since 4.4 */ public int getRcvBufSize() { return rcvBufSize; } /** * @see Builder#setBacklogSize(int) * @since 4.4 */ public int getBacklogSize() { return backlogSize; } /** * @see Builder#setSocksProxyAddress(SocketAddress) */ public SocketAddress getSocksProxyAddress() { return this.socksProxyAddress; } @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("[soTimeout=").append(this.soTimeout) .append(", soReuseAddress=").append(this.soReuseAddress) .append(", soLinger=").append(this.soLinger) .append(", soKeepAlive=").append(this.soKeepAlive) .append(", tcpNoDelay=").append(this.tcpNoDelay) .append(", sndBufSize=").append(this.sndBufSize) .append(", rcvBufSize=").append(this.rcvBufSize) .append(", backlogSize=").append(this.backlogSize) .append(", socksProxyAddress=").append(this.socksProxyAddress) .append("]"); return builder.toString(); } public static SocketConfig.Builder custom() { return new Builder(); } public static SocketConfig.Builder copy(final SocketConfig config) { Args.notNull(config, "Socket config"); return new Builder() .setSoTimeout(config.getSoTimeout()) .setSoReuseAddress(config.isSoReuseAddress()) .setSoLinger(config.getSoLinger()) .setSoKeepAlive(config.isSoKeepAlive()) .setTcpNoDelay(config.isTcpNoDelay()) .setSndBufSize(config.getSndBufSize()) .setRcvBufSize(config.getRcvBufSize()) .setBacklogSize(config.getBacklogSize()) .setSocksProxyAddress(config.getSocksProxyAddress()); } public static class Builder { private Timeout soTimeout; private boolean soReuseAddress; private TimeValue soLinger; private boolean soKeepAlive; private boolean tcpNoDelay; private int sndBufSize; private int rcvBufSize; private int backlogSize; private SocketAddress socksProxyAddress; Builder() { this.soTimeout = DEFAULT_SOCKET_TIMEOUT; this.soReuseAddress = false; this.soLinger = TimeValue.NEG_ONE_SECOND; this.soKeepAlive = false; this.tcpNoDelay = true; this.sndBufSize = 0; this.rcvBufSize = 0; this.backlogSize = 0; this.socksProxyAddress = null; } /** * @see #setSoTimeout(Timeout) */ public Builder setSoTimeout(final int soTimeout, final TimeUnit timeUnit) { this.soTimeout = Timeout.of(soTimeout, timeUnit); return this; } /** * Determines the default socket timeout value for blocking I/O operations. * <p> * Default: 3 minutes * </p> * * @return the default socket timeout value for blocking I/O operations. * @see java.net.SocketOptions#SO_TIMEOUT */ public Builder setSoTimeout(final Timeout soTimeout) { this.soTimeout = soTimeout; return this; } /** * Determines the default value of the {@link java.net.SocketOptions#SO_REUSEADDR} parameter * for newly created sockets. * <p> * Default: {@code false} * </p> * * @return the default value of the {@link java.net.SocketOptions#SO_REUSEADDR} parameter. * @see java.net.SocketOptions#SO_REUSEADDR */ public Builder setSoReuseAddress(final boolean soReuseAddress) { this.soReuseAddress = soReuseAddress; return this; } /** * @see #setSoLinger(TimeValue) */ public Builder setSoLinger(final int soLinger, final TimeUnit timeUnit) { this.soLinger = Timeout.of(soLinger, timeUnit); return this; } /** * Determines the default value of the {@link java.net.SocketOptions#SO_LINGER} parameter * for newly created sockets. * <p> * Default: {@code -1} * </p> * * @return the default value of the {@link java.net.SocketOptions#SO_LINGER} parameter. * @see java.net.SocketOptions#SO_LINGER */ public Builder setSoLinger(final TimeValue soLinger) { this.soLinger = soLinger; return this; } /** * Determines the default value of the {@link java.net.SocketOptions#SO_KEEPALIVE} parameter * for newly created sockets. * <p> * Default: {@code false} * </p> * * @return the default value of the {@link java.net.SocketOptions#SO_KEEPALIVE} parameter. * @see java.net.SocketOptions#SO_KEEPALIVE */ public Builder setSoKeepAlive(final boolean soKeepAlive) { this.soKeepAlive = soKeepAlive; return this; } /** * Determines the default value of the {@link java.net.SocketOptions#TCP_NODELAY} parameter * for newly created sockets. * <p> * Default: {@code false} * </p> * * @return the default value of the {@link java.net.SocketOptions#TCP_NODELAY} parameter. * @see java.net.SocketOptions#TCP_NODELAY */ public Builder setTcpNoDelay(final boolean tcpNoDelay) { this.tcpNoDelay = tcpNoDelay; return this; } /** * Determines the default value of the {@link java.net.SocketOptions#SO_SNDBUF} parameter * for newly created sockets. * <p> * Default: {@code 0} (system default) * </p> * * @return the default value of the {@link java.net.SocketOptions#SO_SNDBUF} parameter. * @see java.net.SocketOptions#SO_SNDBUF * @since 4.4 */ public Builder setSndBufSize(final int sndBufSize) { this.sndBufSize = sndBufSize; return this; } /** * Determines the default value of the {@link java.net.SocketOptions#SO_RCVBUF} parameter * for newly created sockets. * <p> * Default: {@code 0} (system default) * </p> * * @return the default value of the {@link java.net.SocketOptions#SO_RCVBUF} parameter. * @see java.net.SocketOptions#SO_RCVBUF * @since 4.4 */ public Builder setRcvBufSize(final int rcvBufSize) { this.rcvBufSize = rcvBufSize; return this; } /** * Determines the maximum queue length for incoming connection indications * (a request to connect) also known as server socket backlog. * <p> * Default: {@code 0} (system default) * </p> * @return the maximum queue length for incoming connection indications * @since 4.4 */ public Builder setBacklogSize(final int backlogSize) { this.backlogSize = backlogSize; return this; } /** * The address of the SOCKS proxy to use. */ public Builder setSocksProxyAddress(final SocketAddress socksProxyAddress) { this.socksProxyAddress = socksProxyAddress; return this; } public SocketConfig build() { return new SocketConfig( Timeout.defaultsToDisabled(soTimeout), soReuseAddress, soLinger != null ? soLinger : TimeValue.NEG_ONE_SECOND, soKeepAlive, tcpNoDelay, sndBufSize, rcvBufSize, backlogSize, socksProxyAddress); } } }
⏎ org/apache/hc/core5/http/io/SocketConfig.java
Or download all them as a single archive file:
File name: httpcore5-5.2-fyi.zip File size: 812477 bytes Release date: 2022-11-10 Download
⇒ Donwload httpcomponents-client-4.5.3-bin.zip
⇐ Download and Install HttpComponents Core Source Package
2023-03-07, 17869👍, 0💬
Popular Posts:
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...
Xalan-Java, Version 2.7.1, is an XSLT processor for transforming XML documents into HTML, text, or o...
What Is js.jar in Rhino JavaScript 1.7R5? js.jar in Rhino JavaScript 1.7R5 is the JAR file for Rhino...
What Is jaxb-impl-2.1.12.jar? Java Architecture for XML Binding (JAXB) is a Java API that allows Jav...
The Java Naming and Directory Interface (JNDI) is part of the Java platform, providing applications ...