Sorry but I'm still having problems. I tried using unbuffered IO but with the same result (works on the simulator but not on the device). Also the code I sent you was followed by:
// Get buffered Input stream is = link.getInputStream(); BufferedInputStream binp = new BufferedInputStream(is); // Get reply String ans = readLine(binp); which I think would qualify as asking for a response from the server. BTW this is all being done on a separate thread. I'm learning about the REST protocol but think this should work. -Dennis On Saturday, March 6, 2021 at 9:32:02 PM UTC-5 Shai Almog wrote: > Are you using com.codenameone.io.URL ? > I would recommend avoiding BufferedOutputStream in Codename One as all > streams are buffered by default in Codename One. > You also need to fetch the result for the request to finish. It won't > happen until you try to get a response from the server. > > I would recommend using APIs like the "Rest" API which is simpler to use > and doesn't require threading. > > On Saturday, March 6, 2021 at 11:24:53 PM UTC+2 [email protected] wrote: > >> I have the following code that I use to send an email and password to my >> server. It works fine on the simulator but fails on an actual iphone (I >> receive a blank email and password): >> >> try { >> URL url = new URL(*"server address"*); >> link = url.openConnection(); >> link.setDoOutput(true); >> link.setDoInput(true); >> } catch(URISyntaxException e) { >> Log.p("URL error"); >> Log.e(e); >> } >> // Get buffered output stream >> os = link.getOutputStream(); >> BufferedOutputStream bout = new BufferedOutputStream(os); >> // Send email and hashed Password >> bout.write((nemail + "\n").getBytes()); >> pwHash = getHash(nemail + npasswd); >> bout.write((pwHash + "\n").getBytes()); >> bout.flush(); >> >> Thanks, Dennis >> > -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/a10ab990-6563-41a2-ae5c-91ec7268c4e9n%40googlegroups.com.
