public int read() throws IOException { byte[] b = {}; int count = internalRead(b, 0, 1); return count > 0 ? b[0] : -1; }
/** * @param port - the port to listen to * @param backlog - how many connections are queued * @return A ServerSocket * @throws IOException */ public ServerSocket createServerSocket(int port, int backlog) throws IOException { return createServerSocket(port, backlog, null); }
/** * Create a server socket on the specified port (port 0 indicates * an anonymous port). * * @param port the port number * @return the server socket on the specified port * @throws java.io.IOException if an I/O error occurs during server socket * creation * @since 1.2 */ public ServerSocket createServerSocket(int port) throws IOException { ServerSocket activeSocket = new TimeoutServerSocket(port, backlog, bindAddress); return activeSocket; }
Long methodkey = new Long(MethodHash.calculateHash(methods[i])); invokerMap.put(methodkey, methods[i]); handlers[i] = new RMIMultiSocketHandler(obj, invokerMap); stubs[i] = UnicastRemoteObject.exportObject(handlers[i], theport, csf, ssf); obj.getClass().getClassLoader(), interfaces, new RMIMultiSocketClient(stubs)); stubmap.put(remote, stubs); handlermap.put(remote, handlers);
serverSocketFactory = new DefaultSocketFactory(addr); else
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("hashCode")) { return new Integer(stubs[0].hashCode()); } if (method.getName().equals("equals")) { return new Boolean(stubs[0].equals(args[0])); } int i = random.nextInt(stubs.length); long hash = MethodHash.calculateHash(method); RMIMultiSocket target = (RMIMultiSocket)stubs[i]; return target.invoke(hash, args); } }
/** * Create a server socket on the specified port (port 0 indicates * an anonymous port). * @param port the port number * @return the server socket on the specified port * @exception java.io.IOException if an I/O error occurs during server socket * creation * @since 1.2 */ public Socket createSocket(String host, int port) throws IOException { Socket s = new Socket(host, port); s.setSoTimeout(1000); TimeoutSocket ts = new TimeoutSocket(s); return ts; }
} else if (cl.isArray()) return "["+getTypeString(cl.getComponentType()); } else
public InputStream getInputStream() throws IOException { InputStream is = s.getInputStream(); InterruptableInputStream iis = new InterruptableInputStream(is); return iis; }
public static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, int numSockets) throws RemoteException { return exportObject(obj, port, csf, ssf, obj.getClass().getInterfaces(), numSockets); }
public static long calculateHash(Method method) { Map methodHashes = (Map)hashMap.get(method.getDeclaringClass()); if (methodHashes == null) { methodHashes = getInterfaceHashes(method.getDeclaringClass()); // Copy and add WeakHashMap newHashMap = new WeakHashMap(); newHashMap.putAll(hashMap); newHashMap.put(method.getDeclaringClass(), methodHashes); hashMap = newHashMap; } return ((Long)methodHashes.get(method.toString())).longValue(); }
serverSocketFactory = new DefaultSocketFactory(bindAddress); else
public int read(byte[] b) throws IOException { return internalRead(b, 0, b.length); }
/** * Create a server socket on the specified port (port 0 indicates * an anonymous port). * @param port the port number * @return the server socket on the specified port * @exception IOException if an I/O error occurs during server socket * creation * @since 1.2 */ public ServerSocket createServerSocket(int port) throws IOException { return createServerSocket(port, backlog, bindAddress); }
public Socket accept() throws IOException { Socket s = super.accept(); s.setSoTimeout(1000); TimeoutSocket ts = new TimeoutSocket(s); return ts; } }
for(int j = 0; j < parameterTypes.length; j++) methodDesc += getTypeString(parameterTypes[j]); methodDesc += ")"+getTypeString(method.getReturnType());
public int read(byte[] b, int off, int len) throws IOException { return internalRead(b, off, len); }