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

  • SEARCH
  • Home
  • 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 4256974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:25:40+00:00 2026-05-21T05:25:40+00:00

Attempting to perform sockets communication between Android and C# I seem to be stuck.

  • 0

Attempting to perform sockets communication between Android and C# I seem to be stuck.

This is basically the code I have so far.

Android:

public void onClick(View v) {
    try {
        InetAddress serverAddr = InetAddress.getByName("localhost");
        Socket mySocket = new Socket(serverAddr, 666);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

C#:

TcpListener listener = new TcpListener(System.Net.IPAddress.Parse("127.0.0.1"), 666);
listener.Start();

using (Socket socket = listener.AcceptSocket())
{
    using (Stream stream = new NetworkStream(socket))
    {
    }
}

When hitting the line Socket mySocket = new Socket(serverAddr, 666); in my Android application I am getting the following error.

“java.net.ConnectException:
localhost/127.0.0.1:666 – Connection
refused”

Anyone able to guide me as to what I am doing wrong?

PS: I am testing this through the emulator so wondering if there is possibly some sort of limitation about my ability to communicate with other processes running on the machine?

  • 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-21T05:25:41+00:00Added an answer on May 21, 2026 at 5:25 am

    Inside the emulated machine the address 127.0.0.1 is not the host’s loopback interface, it’s the emulated machine’s own loopback interface.

    According to the emulator documentation you can access the host’s loopback interface through the special address 10.0.2.2.

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

Sidebar

Related Questions

I'm attempting to learn a little more about handling sockets and network connections in
I'm attempting to perform a link of previously generated .obj files (using the latest
I'm attempting to perform a DML operation against an Entity Framework model, specifically, an
I'm attempting to perform dynamic sorting of data that I'm putting into grids into
I'm attempting to perform a synchronous write/read in a demux-based client application with MINA
I am attempting to perform the LoadProperty operation from my context to load a
Attempting to follow this Java tutorial . About 63 pages in, you are instructed
I've been attempting to write a Lisp macro that would perfom the equivalent of
Attempting to insert an escape character into a table results in a warning. For
Attempting to print out a list of values from 2 different variables that are

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.