一个完整的Java RMI通讯的例子

完整的代码,请参考附件。
服务器端:
public class RmiUserServiceImpl extends UnicastRemoteObject implements
RmiUserService {

UserService service = new UserServiceImpl();

public RmiUserServiceImpl() throws RemoteException {
}

private static final long serialVersionUID = -7138363701504022490L;

public void create(String username, String password) throws RemoteException {
service.create(username, password);
}

public User login(String username, String password) throws RemoteException {
return service.login(username, password);
}

public static void main(String[] args) throws RemoteException, MalformedURLException, AlreadyBoundException {
LocateRegistry.createRegistry(1099);
Naming.bind("rmi://localhost:1099/UserService", new RmiUserServiceImpl());
System.out.print("Service start");
}

}


客户端:
public class Client {

public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException {
RmiUserService service = (RmiUserService) Naming
.lookup("rmi://localhost:1099/UserService");
//service.create("new_user_01", "new_user_01");
System.out.println(service.login("new_user_01", "new_password_01"));
}

}
Contents 3-1 Introduction........................................................................................................................................................ 3 3-2 Scope.................................................................................................................................................................. 3 3-3 CIP packets over TCP/IP ................................................................................................................................... 3 3-3.1 Unconnected messages .............................................................................................................................. 3 3-3.2 CIP transport class 0 and class 1 connections ............................................................................................ 5 3-3.2.1 CIP transport class 0 and class 1 packets ............................................................................................... 5 3-3.2.2 Behavior of class 0 and class 1 connections (informative) .................................................................... 5 3-3.3 CIP Transport class 2 and class 3 connections ........................................................................................... 6 3-3.4 CIP Transport classes 4 through 6 ............................................................................................................. 6 3-4 Connection Manager object ............................................................................................................................... 6 3-4.1 Connection parameters............................................................................................................................... 6 3-4.2 Connection type ......................................................................................................................................... 7 3-4.3 Priority ....................................................................................................................................................... 7 3-4.4 Trigger Type .............................................................................................................................................. 7 3-4.5 Connection size .......................................................................................................................................... 7 3-4.6 Connection request time-out ...................................................................................................................... 7 3-4.7 Connection path ......................................................................................................................................... 7 3-4.7.1 Network connection ID .......................................................................................................................... 8 3-4.8 Forward_open for CIP transport class 2 and class 3 connections ............................................................ 11 3-4.9 Forward_open for CIP transport class 0 and class 1 connections ............................................................ 11 3-4.9.1 General ................................................................................................................................................. 11 3-4.9.2 Mapping connections to IP multicast addresses ................................................................................... 11 3-4.9.3 Completing the multicast connection (informative) ............................................................................. 12 3-5 CIP transport class 0 and class 1 connected data ............................................................................................. 12 3-5.1 UDP datagrams ........................................................................................................................................ 12 3-5.2 CIP transport class 0 and class 1 packet ordering .................................................................................... 12 3-5.3 Screening incoming connected data ......................................................................................................... 13 3-6 IP multicast scoping and address allocation..................................................................................................... 13 3-6.1 Background (informative) ........................................................................................................................ 13 3-6.1.1 General ................................................................................................................................................. 13 3-6.1.2 Current scoping practices ..................................................................................................................... 14 3-6.1.3 Current address allocation practices..................................................................................................... 14 3-6.1.4 Evolving Internet standards.................................................................................................................. 14 3-6.2 Interim scoping strategy ........................................................................................................................... 15 3-6.3 Interim allocation strategy........................................................................................................................ 15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值