(已完成)java socket-套接字实现类SocketImpl.md

类继承图

1.接口 2.抽象类 3.实现类

接口SocketImpl

/**

 * The abstract class {@code SocketImpl} is a common superclass

 * of all classes that actually implement sockets. It is used to

 * create both client and server sockets.

 * <p>

 * A "plain" socket implements these methods exactly as

 * described, without attempting to go through a firewall or proxy.

 *

 * @author  unascribed

 * @since   JDK1.0

 */

public abstract class SocketImpl implements SocketOptions {

    /**

     * The actual Socket object.

     */

    Socket socket = null; //客户端套接字

    ServerSocket serverSocket = null; //服务器端套接字



    /**

     * The file descriptor object for this socket.

     */

    protected FileDescriptor fd; //套接字的文件描述符



    /**

     * The IP address of the remote end of this socket.

     */

    protected InetAddress address; //以下是ip地址和端口

 

    /**

     * The port number on the remote host to which this socket is connected.

     */

    protected int port;



    /**

     * The local port number to which this socket is connected.

     */

    protected int localport;


复制代码

服务器端套接字类

包含了套接字实现类

public

class ServerSocket implements java.io.Closeable {

    /**

     * Various states of this socket.

     */

    private boolean created = false;

    private boolean bound = false;

    private boolean closed = false;

    private Object closeLock = new Object();



    /**

     * The implementation of this Socket.

     */

    private SocketImpl impl; //套接字实现类


复制代码

客户端套接字类

也包含了套接字实现类

public

class Socket implements java.io.Closeable {

    /**

     * Various states of this socket.

     */

    private boolean created = false;

    private boolean bound = false;

    private boolean connected = false;

    private boolean closed = false;

    private Object closeLock = new Object();

    private boolean shutIn = false;

    private boolean shutOut = false;



    /**

     * The implementation of this Socket.

     */

    SocketImpl impl; //套接字实现类



    /**

     * Are we using an older SocketImpl?

     */

    private boolean oldImpl = false;


复制代码

套接字实现类-简单套接字实现类

class PlainSocketImpl extends AbstractPlainSocketImpl

{

    private AbstractPlainSocketImpl impl;


复制代码

转载于:https://juejin.im/post/5c4dc66c51882522c03ea744

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值