-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
28 lines (25 loc) · 983 Bytes
/
Server.java
File metadata and controls
28 lines (25 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Scanner;
public class Server {
public static void main(String args[]) {
try {
RemoteMessage stub = new RemoteMessage();
//here comes the code to give the server arguments
String ip;
int port;
//Scanner ss1 = new Scanner(System.in);
//ip = ss1.nextLine();
ip="localhost";
Scanner ss2 = new Scanner(System.in);
port = ss2.nextInt();
// create the RMI registry on port
Registry rmiRegistry = LocateRegistry.createRegistry(port);
// path to access is rmi://localhost:5000/messanger
rmiRegistry.rebind("messanger", stub);
System.out.println("Message Server is ready in ip: "+ ip+ " and port: "+port);
} catch (Exception e) {
System.out.println(e);
}
}
}