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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:41:05+00:00 2026-06-15T05:41:05+00:00

I can receive data on c# UDP server i have written through this code

  • 0

I can receive data on c# UDP server i have written through this code but instead of string i have typed in the editText box … i receive android.widget.EditText@xxxxxx on the server. Some Help would be much appreciated.

package com.winmote.pro;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

    private EditText editText1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button1 = (Button) findViewById(R.id.button1);
        editText1 = (EditText) findViewById(R.id.editText1);
        button1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                String cmd= editText1.toString();
                new nwcomm().execute(cmd);

            }
        });
    }

    private class nwcomm extends AsyncTask<String,Void,Void>{

        @Override
        protected Void doInBackground(String... text) {
            // TODO Auto-generated method stub

         String msg=text[0].toString();
                InetAddress to = null;
                try {
                    to = InetAddress.getByName("192.168.0.105");
                } catch (UnknownHostException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                int port=55505;
                DatagramSocket soc = null;
                try {
                    soc = new DatagramSocket();
                } catch (SocketException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                byte[] data = msg.getBytes();
                DatagramPacket pac = new DatagramPacket(data, data.length, to, port);
                try {
                    soc.send(pac);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return null;
            }
        }




    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
  • 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-15T05:41:06+00:00Added an answer on June 15, 2026 at 5:41 am

    You need to ask for the contents of the EditText, not the String representation of the variable… Change this line:

    String cmd= editText1.toString();
    

    To:

    String cmd = editText1.getText().toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems simple but I can't figure it out. I receive post data in
Ive written the following echo server using UDP but i have no idea that
I am creating a UDP Server.I found following code reference from MSDN.Can any one
I have this TCP server running Because UDP server was able to accept large
How can i send and receive data though parallel port using C# .net? Also
How can I receive multipart POST data requests in ASP.NET C#?
I can successfully receive email from SendGrid and process its data. My problem is
I have an iPad app that receives data using UDP sockets. And it has
I'm trying to get a simple send and receive UDP program working, but I'm
I have been recently writing a UDP server for a 2D shooter game I

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.