Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:42:52+00:00 2026-05-25T14:42:52+00:00

I have few question regarding Socket Communication in Android. 1)I have developed server socket

  • 0

I have few question regarding Socket Communication in Android.

1)I have developed server socket app for android that listens to port 8888.

a) When i host my server on the emulator I’m unable to communicate to it through Client application that I have on my PC since both (Emulator & Client) app are on my laptop & on the same network i think that they should be able to communicate with each other.

b) When i deploy the same server app on my android mobile device and try to communicate it through the same Client Application that I have on my PC, the client application gives a timeout exception as its unable to communicate to it.

My first question is How can i test server/client socket app with Emulator & 1 android device? Can i even use my PC’s client socket application to test my server socket?

**I have Client Socket Application for my other application so theres no problem with the client application.

2) My second question is to test my server app on the android device do I have to forward the desired port?
a) For Emulator: How can I forward port?
b) For Device: How can i forward port?
c) Can i forward port programmatically?

**Just for Information:

I’m using Eclipse as android developement tool.

** MY Server Code as there can also be problem with my server socket code too.

Socket socket = null;
            DataInputStream dataInputStream = null;
            DataOutputStream dataOutputStream = null;
            ServerSocket serverSocket = null;
        try
        {  
            serverSocket = new ServerSocket(SERVERPORT);
            System.out.println("Listening :" + SERVERPORT);
            System.out.println("Server IP:" + SERVERIP);
        }
        catch (Exception e) 
        {               
            e.printStackTrace();
        }
        while(true)
        {
            try
            {
                socket = serverSocket.accept();
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                System.out.println("ip: " + socket.getInetAddress());                   
                String str = in.readLine();
                System.out.println("message Received: " + str);
            } 
            catch (Exception e) 
            {                   
                e.printStackTrace();
            }               
            finally
            {
                if( socket!= null)
                {
                    try 
                    {
                        socket.close();
                    }
                    catch (IOException e) 
                    {
                        e.printStackTrace();
                    }
                }
                if( dataInputStream!= null)
                {
                    try
                    {
                        dataInputStream.close();
                    }
                    catch (IOException e) 
                    {
                        e.printStackTrace();
                    }
                }                   
                if( dataOutputStream!= null)
                {
                    try 
                    {
                        dataOutputStream.close();
                    }
                    catch (IOException e) 
                    {
                        e.printStackTrace();
                    }
                }
            }
        }

Edited:
A very interesting part is that if i set port to 8080 PC’s Client Socket App do connect to Android App on my android device but i don’t receive socket on my server nor the data I send. Nothing happens after the link => socket = serversocket.accept();

Also I have set the permission in the manifest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:42:53+00:00Added an answer on May 25, 2026 at 2:42 pm

    For your first question, on how to access the network from the emulator: the emulator runs on its own network address space, isolated from your PC. You have to configure network redirection to access devices on your network.

    See more details in https://developer.android.com/studio/run/emulator-networking.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question. What do you think, I have a few sites that use a
A question that seems to have quite a few options for Python, but none
So I have searched through a few question here regarding the AlertDialog, and I'm
I have a general question regarding synchronized List. Lets say that in the constructor
I am new to Android development and I have a question regarding custom views
I have a few questions regarding WSARecv Question 1: How do I excactly determine
I have few question regarding Silverlight Deployment: Is it a prerequisite to add MIME
I have a few questions regarding android market(Google play). How can I list my
I have a few questions regarding using socket IO with PHP and such, I
i have few question regarding the return statement. a) is it compulsory to define

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.