Jump to content

[Question] Serveur sur Android


gentle972

Recommended Posts

Bonjour,

je vous explique ma situation :

J'essaye de faire une application( simple pour commencer) client/serveur (pc -> client / android -> serveur)

Voici le code du serveur

package com.ser;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

import android.util.Log;

public class Serveur {

public Serveur() {

	try {
		ServerSocket serS = new ServerSocket(3000);
		Socket socket = serS.accept();
		PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
		String a = "Bonjour";
		out.print(a);
		out.close();
		socket.close();
		serS.close();

	} catch (IOException e) {
		e.printStackTrace();
	}

}

}

J'ai bien mis dans le manifest

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Le programme se lance sans mettre d'erreur mais quand je fais un netstat(sur le téléphone) pour voir si le port 3000 est en écoute, il n'y est pas. Donc impossible de connecté un client.

Il y a quelque chose de particulier à faire pour ouvrir un port sur l'andoid ?

Merci d'avance des éventuelles réponse .

ps: j'ai testé l'application sur mon lg.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...