IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Erreur "java.net.bindexception address already in use console:java.net.ConnectException: Connection timed out"


Sujet :

Android

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2015
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2015
    Messages : 2
    Par défaut Erreur "java.net.bindexception address already in use console:java.net.ConnectException: Connection timed out"
    logcat:java.net.bindexception address already in use. at libcore.io.iobridge.blind

    console: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source

    i want to send my file apk from server java to client android in the localhost main activity in my android application:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    public class MainActivity extends Activity implements OnClickListener { public static String ism;
     
    Button btn;
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
     
     
            btn = (Button) findViewById(R.id.but);
            btn.setOnClickListener(this);
            addButtonClickListner();
     
        }
     
        public void addButtonClickListner() {
            Button btnNavigator = (Button)findViewById(R.id.button1);
     
            Button btn3 = (Button) findViewById(R.id.efface);
            btn3.setOnClickListener(new OnClickListener() {
     
                //le button effacer l'historique l'historique
                @Override
                public void onClick(View v) {
                    Initial_historique.lance();
     
                }
            });
     
     
            btnNavigator.setOnClickListener(new OnClickListener() {
     
                //button pour recevoire le .apk appel socket
                @Override
                public void onClick(View arg) {
                    // TODO Auto-generated method stub
     
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
     
                                try {
                                    SocketFromServer.soc();
                                } catch (IOException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
     
                        }   
                          }).start();
     
     
                    //appel au thread pour recevoire 
     
                }
            });
        }
    }


    my class socket in the android application:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    public class SocketFromServer
    {
        public static void soc() throws IOException 
        { 
            Socket sock = new ServerSocket(9001).accept();
     
            Commun.transfert(
                    sock.getInputStream(),
                    new FileOutputStream("/data/data/com.so.and/And1.apk"),
                    true);
     
            sock.close(); 
        } 
    }
    my main in java application:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    public class Serveur
    {
     
     
        public static void main(String[] args) throws IOException, InterruptedException 
        {
                SocketToClient.socket();
     
        }
    }
    my class socket in my java application:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    29
    30
    31
    32
    public class SocketToClient
    {
        public static void socket() throws IOException 
        { 
            Socket sock = new Socket("10.0.2.2",9001);
     
            Commun.transfert(
                    new FileInputStream("C:/Users/admin/Desktop/ws/serveur/And.apk"),
                    sock.getOutputStream(),
                    true);
     
            sock.close();
        } 
    }
     
    public  class Commun extends SocketToClient
    {
        public static void transfert(InputStream in, OutputStream out, boolean closeOnExit) throws IOException
        {
            byte buf[] = new byte[1024];
     
            int n;
            while((n=in.read(buf))!=-1)
                out.write(buf,0,n);
     
            if (closeOnExit)
            {
                in.close();
                out.close();
            }
        }
    }
    Images attachées Images attachées  

Discussions similaires

  1. Réponses: 4
    Dernier message: 16/07/2013, 17h01
  2. Erreur "java.net.BindException: Address already in use: JVM_Bind"
    Par baaab dans le forum Développement Web en Java
    Réponses: 1
    Dernier message: 15/06/2013, 17h35
  3. java.net.BindException: Address already in use: connect
    Par Spiff__ dans le forum Entrée/Sortie
    Réponses: 3
    Dernier message: 10/08/2009, 06h54
  4. [Sockets] Erreur 98 "address already in use"
    Par iReNu dans le forum Réseau/Web
    Réponses: 6
    Dernier message: 17/04/2009, 17h27
  5. java.net.ConnectException: Connection timed out: connect
    Par FrenchFrogger dans le forum Services Web
    Réponses: 1
    Dernier message: 10/02/2009, 14h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo