The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
Re: ServerSocket
[Originally posted by jwhite]

Dan,

Thanks for your interest in J2ME and the book. Included below are comments to
your questions/issues.

Thanks
Jim White & David Hemphill

> > I have tried to follow your instructions to create a serversocket on my
> > Palm. I can't get this to work. Please help me...
> >
> > The source code for SocketListener doesn't compile on my PC because it
> > doesn't understand the ServerSocket. I am using the Forte 4 ME. If I compile
> > code that will dynamically load the class
> > "com.sun.........serversocket.Protocol" it works in that, the class is in my
> > Palm pilot's VM. I can't "Connector.open("serversocket://:"...... because
the
> > Palm states that the protocol is unsupported. I believe that it is actually
> > supported, but it can't FIND the serversocket class because the compiler is
> > not including it, and maybe the VM is looking at the WRONG protocol.
> >
> > I can write the Connector.open("socket://localhost:444"... all day long
and
> > everything works fine.
> >
> > I can do an "import com.sun.cldc.io.j2me.serversocket.Protocol;" and at
> > least it will compile with the "serversocket", but it won't work right.
Also,
> > the compiler will refuse to compile with a "datagram.Protocol".
> >
> > I can't seem to find info on how to include the cldc package into my
forte.
> > Can you help me to import the correct stuff?
>
>
>
> Now, I have compiled your examples with the j2me toolkit as an "ide". It
> compiled fine, and ran fine on my Palm, however, the System.out.println
> doesn't work on the Palm... no big deal, but should it??

The system.out.println does work on Palm, but you will find the results of any
system outs in a file called stdout.txt located in your emulator directory.
The system.out lines do not send text back to the Wireless toolkit console
like the other emulators do.


> Anyway, it runs fine on my Palms, but the exception it throws when trying to
> start the socketserver listener is : "Unsupported protocol serversocket". How
> disheartening! Am I to believe that after all this head banging and torture,
> that my palm simply doesn't support the serversocket protocol?

Socketserver is supported...I think we need a few more details? What are
using (IDE, virtual machine, etc.)? Serversocket should be supported by MIDP
for Palm OS (except if you are trying to connect by IR port as suggested
below)? What are you trying to connect and are you using MIDP for Palm OS or
Jbed or something else?
>
> Is there no way possible to send info between the IR ports between 2 palms or
> between a PC and an IR port?
Palm IR port communication is not directly supported under the implementations
of J2ME. This is coming (hopefully with PDAP and MIDP NG) but not there yet.
You may want to take a look at things like VAME, if you need this support in
your Java environment right now and you don't want to have to modify the VM
yourself.
>
> please feel free to email me at poppakap@yahoo.com

We appreciate the opportunity to correspond with our readers directly, but
answers in the forum help others that may have the same question. Therefore,
we encourage everyone to post and answer questions by the forum.
> thank you...
import-bot (20211) [Avatar] Offline
#2
[Originally posted by poppakap]

I have tried to follow your instructions to create a serversocket on my
Palm. I can't get this to work. Please help me...

The source code for SocketListener doesn't compile on my PC because it
doesn't understand the ServerSocket. I am using the Forte 4 ME. If I compile
code that will dynamically load the class
"com.sun.........serversocket.Protocol" it works in that, the class is in my
Palm pilot's VM. I can't "Connector.open("serversocket://:"...... because the
Palm states that the protocol is unsupported. I believe that it is actually
supported, but it can't FIND the serversocket class because the compiler is
not including it, and maybe the VM is looking at the WRONG protocol.

I can write the Connector.open("socket://localhost:444"... all day long and
everything works fine.

I can do an "import com.sun.cldc.io.j2me.serversocket.Protocol;" and at
least it will compile with the "serversocket", but it won't work right. Also,
the compiler will refuse to compile with a "datagram.Protocol".

I can't seem to find info on how to include the cldc package into my forte.
Can you help me to import the correct stuff?
import-bot (20211) [Avatar] Offline
#3
Re: ServerSocket
[Originally posted by poppakap]

> I have tried to follow your instructions to create a serversocket on my
> Palm. I can't get this to work. Please help me...
>
> The source code for SocketListener doesn't compile on my PC because it
> doesn't understand the ServerSocket. I am using the Forte 4 ME. If I compile
> code that will dynamically load the class
> "com.sun.........serversocket.Protocol" it works in that, the class is in my
> Palm pilot's VM. I can't "Connector.open("serversocket://:"...... because the
> Palm states that the protocol is unsupported. I believe that it is actually
> supported, but it can't FIND the serversocket class because the compiler is
> not including it, and maybe the VM is looking at the WRONG protocol.
>
> I can write the Connector.open("socket://localhost:444"... all day long and
> everything works fine.
>
> I can do an "import com.sun.cldc.io.j2me.serversocket.Protocol;" and at
> least it will compile with the "serversocket", but it won't work right. Also,
> the compiler will refuse to compile with a "datagram.Protocol".
>
> I can't seem to find info on how to include the cldc package into my forte.
> Can you help me to import the correct stuff?



Now, I have compiled your examples with the j2me toolkit as an "ide". It
compiled fine, and ran fine on my Palm, however, the System.out.println
doesn't work on the Palm... no big deal, but should it??
Anyway, it runs fine on my Palms, but the exception it throws when trying to
start the socketserver listener is : "Unsupported protocol serversocket". How
disheartening! Am I to believe that after all this head banging and torture,
that my palm simply doesn't support the serversocket protocol?

Is there no way possible to send info between the IR ports between 2 palms or
between a PC and an IR port?

please feel free to email me at poppakap@yahoo.com
thank you...
import-bot (20211) [Avatar] Offline
#4
Re: ServerSocket
[Originally posted by poppakap]

Hey Jim, glad to get a response from you so fast!


> The system.out.println does work on Palm, but you will find the results of any
> system outs in a file called stdout.txt located in your emulator directory.
> The system.out lines do not send text back to the Wireless toolkit console
> like the other emulators do.
>
Ahhh! Ok. I had seen this file, but didn't pursue finding out where it came
from. Cool...

> Socketserver is supported...I think we need a few more details? What are
> using (IDE, virtual machine, etc.)?

I was using Forte, which wouldn't compile, but now I'm using the WTK to
compile and the Sun prc converter tool to make my prc file. My 2 Palm pilots
used for testing are m100, which have the 3.5 version of Palm OS. The virtual
machine is Java HQ 1.0, the MIDP for Palm OS.

> Serversocket should be supported by MIDP
> for Palm OS (except if you are trying to connect by IR port as suggested
> below)?

Yes, that was how I was trying to get them to communicate. I thought that you
said two devices could communicate to each other using an infrared link
between the two devices (p. 382, fig 13.5)? Did I misunderstand this or read
too much into it? If serversocket protocol is supported, why does the
exception say the is isn't? What I mean is, how does the Palm OS know I am
pointing one IR at the other? Do the Palm pilot's network settings come into
play here?

> > Is there no way possible to send info between the IR ports between 2 palms
or
> > between a PC and an IR port?

> Palm IR port communication is not directly supported under the implementations
> of J2ME. This is coming (hopefully with PDAP and MIDP NG) but not there yet.
> You may want to take a look at things like VAME, if you need this support in
> your Java environment right now and you don't want to have to modify the VM
> yourself.

Modifying the VM sounds like it would be quite painful. I'll definately look
into VAME, thanks... I should probably give you a little more information. My
company manufactures a device that they would like for the end user to be able
to query for data, or download firmware to. What information the device wants
isn't important to this topic, but I have been told to investigate ways to use
a Palm or other handheld device, to send data back and forth to this device.
Our first choice would be to use the IR port. If this isn't feasible with
Java, we are open to using USB or serial, or even perhaps writing the
networking piece in C. I'd personally like to keep everything in Java, but if
we have to split things up to get it done... oh well.
import-bot (20211) [Avatar] Offline
#5
Re: ServerSocket
[Originally posted by mulyap21]

> Hey Jim, glad to get a response from you so fast!
>
>
> > The system.out.println does work on Palm, but you will find the results of
any
> > system outs in a file called stdout.txt located in your emulator directory.
> > The system.out lines do not send text back to the Wireless toolkit console
> > like the other emulators do.
> >
> Ahhh! Ok. I had seen this file, but didn't pursue finding out where it came
> from. Cool...
>
> > Socketserver is supported...I think we need a few more details? What are
> > using (IDE, virtual machine, etc.)?
>
> I was using Forte, which wouldn't compile, but now I'm using the WTK to
> compile and the Sun prc converter tool to make my prc file. My 2 Palm pilots
> used for testing are m100, which have the 3.5 version of Palm OS. The virtual
> machine is Java HQ 1.0, the MIDP for Palm OS.
>
> > Serversocket should be supported by MIDP
> > for Palm OS (except if you are trying to connect by IR port as suggested
> > below)?
>
> Yes, that was how I was trying to get them to communicate. I thought that you
> said two devices could communicate to each other using an infrared link
> between the two devices (p. 382, fig 13.5)? Did I misunderstand this or read
> too much into it? If serversocket protocol is supported, why does the
> exception say the is isn't? What I mean is, how does the Palm OS know I am
> pointing one IR at the other? Do the Palm pilot's network settings come into
> play here?
>
> > > Is there no way possible to send info between the IR ports between 2 palms
> or
> > > between a PC and an IR port?
>
> > Palm IR port communication is not directly supported under the
implementations
> > of J2ME. This is coming (hopefully with PDAP and MIDP NG) but not there
yet.
> > You may want to take a look at things like VAME, if you need this support in
> > your Java environment right now and you don't want to have to modify the VM
> > yourself.
>
> Modifying the VM sounds like it would be quite painful. I'll definately look
> into VAME, thanks... I should probably give you a little more information. My
> company manufactures a device that they would like for the end user to be able
> to query for data, or download firmware to. What information the device wants
> isn't important to this topic, but I have been told to investigate ways to use
> a Palm or other handheld device, to send data back and forth to this device.
> Our first choice would be to use the IR port. If this isn't feasible with
> Java, we are open to using USB or serial, or even perhaps writing the
> networking piece in C. I'd personally like to keep everything in Java, but if
> we have to split things up to get it done... oh well.

I've tried the serversocket example listing on page 392 using midp 1.0.3
without much success. The server is reporting "Problems sending or receiving
data.
javax.microedition.io.ConnectionNotFoundException: The requested protocol does n
ot exist serversocket://localhost:4000". anybody could help with this problem.
I'm using windows XP home edition.
sivaram_y (1) [Avatar] Offline
#6
Re: ServerSocket
Hi,

I am having same problem while creating serversocket on palm. I used "Connector.open("serversocket://:8000")" to create serversocket. While running the application to start listener, the exception raised is javax.microedition.io.ConnectionNotFoundException: unsupported protocol: serversocket.

I am using J2ME wireless toolkit to compile the code, MIDP 1.0 and Palm OS emulator to run the application. I went through the whole discussions on this subject in this page and couldn't able to find the right solution for this. If this problem has been solved at your end, kindly share the solution. Waiting for the solution becoz I require the solution asap.

Regards,
SRK.
thanray (2) [Avatar] Offline
#7
Re: ServerSocket
Hi,

I browsed the thread, and just wondered isnt it possible to use Server socket in a J2ME, MIDP 2.0? Is it only available for CDC configuration (palm) and not for CLDC (mobile phones)
- tk
thanray (2) [Avatar] Offline
#8
Re: ServerSocket
You are creating it wrong way..

Try to do like this:
// create a server socket connection with spesified url
con = (ServerSocketConnection)
Connector.openInputStream(host);

// wait for connection
SocketConnection socketConn = (SocketConnection) con.acceptAndOpen();

// Setting application- spesific properties
// wait for connection in
socketConn.setSocketOption(SocketConnection.LINGER,
timeOut);
// dissable waiting delay
socketConn.setSocketOption(SocketConnection.DELAY, 0);