⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmiserver.java

📁 test upload file 1111111
💻 JAVA
字号:
package com.vest.kungfu.utility;

import java.net.InetAddress;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Date;

public class RmiServer extends java.rmi.server.UnicastRemoteObject implements
		InterfaceCrc

{
	int thisPort;

	String thisAddress;

	Registry registry; // rmi registry for lookup the remote objects.

	public String crc(String code) throws RemoteException {
		// TODO Auto-generated method stub
		Pwdcrc crc=new Pwdcrc(); 
		return crc.CRCPassword(code);
	}

	public RmiServer() throws RemoteException

	{

		try {

			// get the address of this host.

			thisAddress = (InetAddress.getLocalHost()).toString();

		}

		catch (Exception e) {

			throw new RemoteException("can't get inet address.");

		}

		thisPort = 3232; // this port(registry’s port)

		System.out.println("-->Local:" + thisAddress + ",port=" + thisPort);

		try {

			// create the registry and bind the name and object.

			registry = LocateRegistry.createRegistry(thisPort);

			registry.rebind("RMICRC", this);
			System.out.println("-->RMI服務器啟動了!等待客戶端的連接 @"+(new Date())); 

		}

		catch (RemoteException e) {

			throw e;

		}

	}

	static public void main(String args[])

	{

		try {

			RmiServer s = new RmiServer();

		}

		catch (Exception e) {

			e.printStackTrace();

			System.exit(1);

		}

	}

}

⌨️ 快捷键说明

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