StreamConnection / StreamConnectionNotifier problem.

B

Boki

To create a server connection:
we have to do:

service = (StreamConnectionNotifier) Connector.open(url);
con = (StreamConnection) service.acceptAndOpen();

I don't know why we have to do these,

my question:
why convert StreamConnectionNotifier(service) to StreamConnection(con) ?

It seems that when we implement a client code, we don't have to do that,
isn't it ?:)
ex: we only have to do this:
StreamConnection con = (StreamConnection) Connector.open( url );

Best regards,
Boki.
 
T

Thomas Hawtin

Boki said:
To create a server connection:
we have to do:

service = (StreamConnectionNotifier) Connector.open(url);
con = (StreamConnection) service.acceptAndOpen();

I don't know why we have to do these,

my question:
why convert StreamConnectionNotifier(service) to StreamConnection(con) ?

It seems that when we implement a client code, we don't have to do that,
isn't it ?:)
ex: we only have to do this:
StreamConnection con = (StreamConnection) Connector.open( url );

It might help to mention that these interfaces are in the
javax.microedition.io package. They are roughly equivalent to
java.net.ServerSocket and Socket.

In general, to receive an incoming connection you need to tell the
operating system that you are prepared to accept that service. An
incoming connection should be dealt with immediately, even if that just
means being put into a queue.

You probably want to know immediately whether the operating system is
going to permit it or not. If another program is listening to that port,
then you probably will not be able to.

Also subtypes of StreamConnectionNotifier may provide additional
information and options.

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top