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 8269669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:18:23+00:00 2026-06-08T06:18:23+00:00

I have a socket, I’m trying to send information from the client to the

  • 0

I have a socket, I’m trying to send information from the client to the server. Both are located on the same network, with different LAN IP’s (as follows):

My server is my C# application. – 192.168.0.2
My client is my Android application. – 192.168.0.7

Here’s my TcpListener for the server:

server = new TcpListener(IPAddress.Parse("192.168.0.7"), 7079);

Here’s my connection on the client:

Socket conn = new Socket("192.168.0.2", 7079);

Firstly, I wasn’t sure what to put as the TcpListener IP. Obviously what I have is wrong, because it throws a SocketException: The requested address is not valid in its context.

EDIT:

First problem is resolved, I ran using emulator and put 10.0.2.2 for the connection IP. Now, C# is throwing an exception. Here’s the surrounding code:

full code removed to prevent leaching

On the line beginning with while, I get an ObjectDisposedException saying that the NetworkStream is disposed. Any help?

  • 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-06-08T06:18:24+00:00Added an answer on June 8, 2026 at 6:18 am

    You should not be putting an IP address for the TCP Listener. The IP address that clients will use to connect to is just the IP address of the computer. Only the client should add an IP address for where the Socket should connect to.

    edit: By that I mean you should be using “127.0.0.1” for the TCPListener because that points to itself. Then you accept the client using the AcceptTcpClient method.

    Found you an example http://theanti9.wordpress.com/2008/02/13/c-tcplistener-example/

    another edit: Sorry, maybe it is IPAddress.Any for the Listener IP Address? My C# is rusty for what it expects, but it should be one of those two.

    another edit: After looking at your latest code edit, you are calling client.Close() in your listening loop. This is causing the client to close the Socket connection and thus invalidate the Stream object you created. That is why it is giving you the ObjectDisposed error, because the Stream doesn’t exist anymore.

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

Sidebar

Related Questions

I have socket program which sends a file from socket client to socket server
I have a socket server running on an android device. Then from a client
I have a socket client that would read data from the server. However, it
I have c++ socket server and android client. Server constantly sends data to the
I have a socket based server which accepts client connections. The problem is server
I have a socket.io server running and a matching webpage with a socket.io.js client.
I have a socket server that I am trying to move over to SSL
I have a socket comminucation between Perl client and C++ server. Perl code: if
I have a socket server which I am writing in C++ and a client
I have a socket.io server listening for certain events on sockets. Whenever an event

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.