identityserversocket.java

来自「最新的关于精通rmi这本书的源码」· Java 代码 · 共 61 行

JAVA
61
字号
/*
 * Copyright 1999 by dreamBean Software,
 * All rights reserved.
 */
package masteringrmi.hellosocket.server;

import java.io.IOException;
import java.net.Socket;
import java.net.ServerSocket;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import masteringrmi.hellosocket.interfaces.IdentitySocket;

/**
 *   This is a custom server socket. It can be used to accept
 *   connections from an IdentitySocket.   
 *      
 *   @see HelloWorld
 *   @author Rickard 謆erg
 *   @version $Revision:$
 */
public class IdentityServerSocket
   extends ServerSocket
{
   // Attributes ----------------------------------------------------
   
   
   // Constructors --------------------------------------------------

   /**
    *   Create a new server socket
    *
    * @param   port  the port which it should listen to
    * @exception   IOException  thrown if creation failed
    */
   protected IdentityServerSocket(int port)
      throws IOException
   {
      super(port);
   }
      
   // Constructors --------------------------------------------------

   // Public --------------------------------------------------------

   /**
    *   Listen for incoming connection requests, and create a socket 
    *   with which to talk to the client.
    *
    * @return     a socket connected to a client
    * @exception   IOException  thrown if connection creation failed
    */
   public Socket accept()
      throws IOException
   {
      Socket socket = new IdentitySocket();
      implAccept(socket);
      return socket;
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?