Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

to built a routine in a server that tell me when a .swf file in a client web browser is unloade

  Asked By: Maria    Date: Aug 17    Category: Java    Views: 590
  

I need
to built a routine in a server that tell me when a .swf file in a client web
browser is unloaded. I did some code that works fine for a single connection
but when I start to open multiple connections the java code starts to "nest"
them instead of throw the results in paralel (which is what I want). I guess
I need to work with threads but after a while I realized I can't handle
them. Can anyone help this lonely soul???
THKS 2 ALL.

import java.lang.*;
import java.net.*;
import java.io.*;

public class Escuchador2 {
public static void main(String args[]) {
try {

ServerSocket escucha = new ServerSocket(1024);
int puerto = escucha.getLocalPort();

System.out.println("Escuchador Activo en el puerto: " + puerto);

while (true) {

Socket cliente = escucha.accept();

while(true) {

String ordenadorEntrante1 = cliente.getInetAddress().getHostAddress();
String ordenadorEntrante2 = cliente.getInetAddress().getHostName();
int puertoSalida = cliente.getPort();

System.out.println("Aceptada la coneccion de: " + ordenadorEntrante2 +
" (" + ordenadorEntrante1 + ")");

BufferedReader flujoEntrada = new BufferedReader(new
InputStreamReader(cliente.getInputStream()));

System.out.println("Texto recibido: " + flujoEntrada.readLine());
System.out.println("Chau");

flujoEntrada.close();
cliente.close();
}
}

} catch (IOException e) {

System.out.println("Error.");

}
}



}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Earl Stone     Answered On: Aug 17

Hi not use Servlet comunicate by post

 




Tagged: