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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:03:01+00:00 2026-05-13T18:03:01+00:00

I am trying to develop a TCP client that runs on mobile devices using

  • 0

I am trying to develop a TCP client that runs on mobile devices using MIDP 2.0 and CLDC 1.1. I am trying some sample code, and I have the following problem:

I get a weird exception when I try to read the data back (From the MIDlet).

This is my code:

            //Wait for an incoming message
            firstByte = in.read();
            ByteArrayOutputStream textRecieved = new ByteArrayOutputStream();   //Will be used to hold the data
            if (firstByte >= 0 )
            {                    
                int messageSize = this.in.available();

                //Read the message
                while (messageSize > 0)
                {
                    byte[] buffer = new byte[messageSize];  
                    this.in.read(buffer);
                    textRecieved.write(buffer);
                    messageSize = this.in.available();   //Just in case the server sent the request in chunks.
                    System.out.println("Reading...");
                }
            }
            textRecieved.close();

This is the exception I get:

java.io.IOException: Unknown error 10053 during socket::read 
        at com.sun.midp.io.j2me.socket.Protocol.read0(), bci=0
        at com.sun.midp.io.j2me.socket.Protocol.nonBufferedRead(), bci=12
        at com.sun.midp.io.BufferedConnectionAdapter.readBytes(), bci=36
        at com.sun.midp.io.BaseInputStream.read(), bci=227
        at com.sun.midp.io.BufferedInputStream.fill(), bci=172
        at com.sun.midp.io.BufferedInputStream.read(), bci=16
        at hello.Client.run22222(Client.java:60)
        at hello.HelloMIDlet.startApp(HelloMIDlet.java:193)
        at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
        at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
        at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
        at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
        at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
        at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
        at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

The line that causes the exception is this:

firstByte = in.read();

I am reading on a separate thread. I experienced the same error when I sent requests and tried to read them using the same server. The server is a simple echo server, nothing complex.

P.S. I know that the way the code is written looks like C#, but it is Java, I find it easier to read and follow this way.

Thanks.

  • 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-13T18:03:01+00:00Added an answer on May 13, 2026 at 6:03 pm

    This example seems to be working:
    http://www.java-samples.com/j2me/socket-connection-free-j2me-sample-program.htm

    Could it be that the problem was that I was implementing the client as a class called by the midlet?

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

Sidebar

Related Questions

Trying to develop using MVVM: I have this Csla.PropertyStatus control that is created in
im trying to develop an app for a win CE mobile device that downloads
trying to develop web form using jquery. all i need is to have several
I am trying to develop a mobile app, that registered with a Java program
Im trying to develop a simple java code which will upload some contents from
I'm to trying to develop a program to transfer files using TCP (in a
Im trying to develop an application that should show a map using the Google
Im trying to develop service that starts by bootup receiver if the wifi or
Im trying to develop my first ASP.NET MVC web app and have run into
I am trying to develop a multi-screen app for the Google TV platform using

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.