• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Socket Connetion With MIDP

 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I wud like to know if we can make a socket connection to a non http server thru MIDp.
is there any package in midp to do the same??
Regds
Gautham Kasinath
P.S. please reply asap.
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i guess no one knows ne ting bout wot i asked for..
just my luck...

Gautham Kasinath
 
Eric Giguere
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MIDP only mandates support for HTTP connections. Vendors are free to provide other types of connections, but then your app is non-portable. For maximum portability you can only count on and use HTTP.
------------------
Eric Giguere
author of:
Java 2 Micro Edition : A Professional Developer's Guide
PalmTM Database Programming: The Complete Developer's Guide
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well I read on the Sun tutorials that socket://ip :port enables a socket connection.. well I tried it and failed.. it just wudnt work.. why??
More over if I m running a dedicated server dedicated to my application how do I make the MIDP Client connect to it??
example .. a chat application.
Regds
Gautham Kasinath

[This message has been edited by gautham kasinath (edited April 16, 2001).]
 
Eric Giguere
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't work because the MIDP doesn't support it. The CLDC reference implementation does support it, but only as an example and it's not required to be supported by any profiles built on top of the CLDC. So the only thing you can do is use HTTP to talk to your application running on a web server.
Eric
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well I guess you are right.. there aint no support for Socket... But then how do I make it talk to my dedicated Server..
The idea I have is a scale down of JINI tech.. I have a dedicated Server on one machine.. and when any appliance comes alive it connects to the Server.. thus the Server and all the machines connected to the Server now knows that the appliance is alive.. With object serialisation I intend to trigger methods on the network of appliances..
Please guide me..
Regds
Gautham Kasinath
 
Eric Giguere
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just think of HTTP as your communication protocol. Instead of sending your data over a socket connection, send it using POST commands to a servlet running on the web server, and get the data back from the HTTP response. You can use your own format for the data, just make sure to exchange it using a MIME type of application/octet-stream or something similar.
Eric
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gee tanx..
I guess I shall try a simple code for the same and get back to ya on it.
Regds
Gautham Kasinath
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well it aint working!!
Please help me..
Regds
Gautham Kasinath
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some body help me!!
Regds
Gautham Kasinath
 
Eric Giguere
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a servlet or a JSP or a CGI program setup on your web server? If not, that's the first thing you'll need to do. Then what you do is called Connector.open() with the URL to your servlet/JSP/CGI as the parm and get back an HttpConnection object. Then you call openOutputStream() to get an output stream to write your data to (if you need to send data), then you call getResponseCode() to actually send the data and wait for a response. If the response code is OK you then call openInputStream() to get the data from the response.
Note that if your webserver does any redirection back to your app you'll have to handle that as a special case....
Eric
reply
    Bookmark Topic Watch Topic
  • New Topic