Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
+ Reply
Results 1 to 1 of 1
  1. Thread Author  Thread Author    #1  
    AC Question
    AC Question's Avatar
    Guest

    Exclamation Error in Server socket in service

    Dear all,

    In my app ,i start the service while clicking the button ,
    1.Once service start ,in thread started to broadcast IP Address Using UDP packet
    2.second thread is start running to accept the another socket connection.
    issue :
    Unable to accept the connection from client .

    If in activity program running successfully ,Code as below

    class SocketServerThread extends Thread {
    ServerSocket serverSocket;
    int alerBoxFlag = 0;
    static final int SocketServerPORT = 8888;
    DataInputStream in;
    Socket socket;
    @Override
    public void run() {
    System.out.println("INSIDE SERVER");
    try {
    System.out.println("open ");
    serverSocket = new ServerSocket(SocketServerPORT);
    serverSocket.setReuseAddress(true);
    System.out.println("open 1 ");
    while (true)
    {
    socket = serverSocket.accept(); // this line is not executed
    socket.setReuseAddress(true);
    in = new DataInputStream(socket.getInputStream());
    msg = in.readUTF();
    System.out.println("Socket not connected");
    }
    } catch (SocketException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    System.out.println(e);
    System.out.println("error socket not connecting");

    }catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    System.out.println(e);
    }
    finally
    {
    try
    {
    if (socket!=null || serverSocket !=null)
    {
    socket.close();
    serverSocket.close();
    in.close();
    }else
    {
    }
    }catch (Exception e) {
    // TODO: handle exception
    }}}}


    Please Help me out
    Thanks in advance
    bhagavath ram

Similar Threads

  1. Color issue in gallery view
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 09-08-2014, 02:42 AM
  2. How to access folders created in internal storage?
    By AlokArya in forum Moto G (2013)
    Replies: 4
    Last Post: 08-08-2014, 09:12 PM
  3. HTC android phone with 960 error
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 08-07-2014, 07:36 AM
  4. Samsung Note: No Sound in Settings of the Device
    By Asaf Shaanan in forum Ask a Question
    Replies: 1
    Last Post: 08-07-2014, 06:51 AM
  5. White Background showing black in galley
    By AC Question in forum Ask a Question
    Replies: 0
    Last Post: 08-07-2014, 04:54 AM

Posting Permissions