elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  Ayuda con mi codigo. (Enviar buffer de imagen de c++ a java)(SOCKETS)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con mi codigo. (Enviar buffer de imagen de c++ a java)(SOCKETS)  (Leído 1,561 veces)
70N1


Desconectado Desconectado

Mensajes: 355


Ver Perfil
Ayuda con mi codigo. (Enviar buffer de imagen de c++ a java)(SOCKETS)
« en: 18 Diciembre 2015, 16:59 pm »

Estoy intentando hacer streaming capturando la pantalla del pc y enviando el buffer por socket a
java(Android).

Al parecer mi codigo funciona bien pero al poco de iniciar el streaming me da error en java(Android)

Alguna idea?.

Este es mi codigo de c++:
Código:

                        byte* buffer=NULL;

                        ULONG tamañobuffer=NULL;

                        ULONG comprobacion = NULL;

                        CapturarPantalla(buffer,tamañobuffer, 50);


long int NetInt;

NetInt = htonl((unsigned)tamañobuffer);

                        send(s2, (char *)&NetInt, sizeof(long), 0);

recv(s2,(char*)&comprobacion,sizeof(long),0);

                        long int hostint = ntohl(comprobacion);

printf("\n%lu\n", hostint);

send(s2, (char*)buffer,(int) tamañobuffer, 0);

Y mi codigo java es este :

Código:

  private Runnable updateTask = new Runnable () {
 
    public void run() {
   
            int tamaño=0;
   
    try {
        InStream = new DataInputStream(btSocket.getInputStream());
tamaño= InStream.readInt();


    } catch (IOException e) {

        e.printStackTrace();
        }
   
   
    try {

                                        outStream= new DataOutputStream(btSocket.getOutputStream());
outStream.writeInt(tamaño);
 
} catch (IOException e) {

// TODO Bloque catch generado automáticamente

e.printStackTrace();
}

                    int bufferSize = 1024;

                            byte[] buffer = new byte[bufferSize];
 
                    int totalBytesRead = 0;

                    int numBytesRead   = 0;

                    byte[] result = new byte[tamaño];
   
    while (totalBytesRead != tamaño )
      {
   
    try {
numBytesRead    = InStream.read(buffer);
} catch (IOException e) {
// TODO Bloque catch generado automáticamente
e.printStackTrace();
}
   
    System.arraycopy(buffer, 0, result, totalBytesRead, numBytesRead);
         
    totalBytesRead += numBytesRead;
           }
     
                         Bitmap bmp = BitmapFactory.decodeByteArray(result, 0, tamaño);
       
                                             ImageView image = (ImageView) findViewById(R.id.imageView1);
                   
                                             image.setImageBitmap(bmp);
     
                           buffer = null;
                       
                                              totalBytesRead = 0;
     
                                             numBytesRead   = 0;
         
                                             result=null;
     


     
                  mHandler.postDelayed(updateTask, 20);

           
    }
};
 



En línea

70N1
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
URGENTE!!! ENVIAR ARCHIVOS POR MEDIO DE SOCKETS EN JAVA
Java
SAHEKA_14 2 7,132 Último mensaje 16 Diciembre 2009, 00:47 am
por Blitzkrieg'
ayuda con sockets en java
Java
vincentlaw 1 4,239 Último mensaje 23 Octubre 2012, 15:50 pm
por cruz_lazcano
Ayuda con Sockets en java
Java
juancaa 1 1,780 Último mensaje 28 Agosto 2012, 03:35 am
por xmbeat
[Ayuda] Código para seguimiento de contorno en imagen JAVA
Java
alex.mg 5 2,632 Último mensaje 12 Septiembre 2013, 11:20 am
por Alien-Z
Ayuda con Sockets PHP y Java [RESUELTO]
PHP
LaThortilla (Effort) 1 2,743 Último mensaje 7 Mayo 2017, 01:44 am
por LaThortilla (Effort)
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines