Riciao a tutti....
Mi servirebbe capire come fare un server ed un client P2P....NON MI SERVE un codice funzionante ma una spiegazione su come procedere (voglio capire il ragionamento)....
Io avevo pensato di fare un server così:
quindi credo un P2PServer socket, accept del canale e apro il buffer di scrittura lettura......và bene questo ragionamento o devo aggiungere qualcos'altro?codice:public class Server { public static void main(String args[]) { try { // start a server socket ServerSocket server = new P2PServerSocket(hostname, port); // wait for a client System.out.println("Waiting for client..."); Socket client = server.accept(); System.out.println("Client Accepted."); // now communicate with this client DataInputStream in = new DataInputStream(client.getInputStream()); DataOutputStream out = new DataOutputStream(client.getOutputStream()); out.writeUTF("Hello client world!"); String results = in.readUTF(); //other operation // shut everything down! client.close(); server.close(); } catch (Exception e) { ..................... } } }

					
					
					
						
  Rispondi quotando