The Artima Developer Community
Sponsored Link

Java Answers Forum
InputStream and OutputStream dont work proper

1 reply on 1 page. Most recent reply: Jul 16, 2006 1:41 PM by Dave Hinton

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
bilal ahmed

Posts: 1
Nickname: bilalahmed
Registered: Jul, 2006

InputStream and OutputStream dont work proper Posted: Jul 14, 2006 10:51 AM
Reply to this message Reply
Advertisement
hi iam making a j2me msn messenger the problem is that after opening the connection i get the inputstream and the outputstream for the connection now when i send the first string for authentication the server replies accurately but when i send the second string and try to print the server response there is no string that gets printed and nothing hapens it seems like that the application gets halted.
please tell me the solution to the code below .
thanks alot


String url = "socket://" +"messenger.hotmail.com"+ ":" +1863;

sc = (SocketConnection) Connector.open(url);

in = sc.openInputStream();
out = sc.openOutputStream();

/////////////////connection opened
String str="VER 1 MSNP8 CVR0\r\n";
out.write((str+ "\r\n").getBytes());
out.flush();
StringBuffer sb = new StringBuffer();
int c = 0;
while (((c = in.read()) != -1) ) {//response of the first string
sb.append((char) c);
}
System.out.println(sb.toString());

//////server replies and the string gets printed uptil above accurately

String str2="CVR 2 0x0409 win 2000 i386 MSNMSGR 5.0.0544 MSMSGS cybrog_ed@hotmail.com\r\n";
out.write((str2+ "\r\n").getBytes());
out.flush();
StringBuffer sb1 = new StringBuffer();
int c1 = 0;
while (((c1 = in.read()) != -1) ) {///response of the second string
sb1.append((char) c1);
}
System.out.println(sb1.toString());
////////////for the above sb1.toString() there is no response WHY??????
[\code]


Dave Hinton

Posts: 42
Nickname: catbells
Registered: Oct, 2003

Re: InputStream and OutputStream dont work proper Posted: Jul 16, 2006 1:41 PM
Reply to this message Reply
/////////////////connection opened
String str="VER 1 MSNP8 CVR0\r\n";
out.write((str+ "\r\n").getBytes());


Are you supposed to send the blank line?

Flat View: This topic has 1 reply on 1 page
Topic: String to Integer problem Previous Topic   Next Topic Topic: How can I limit the number of characters entered into a JTextField?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use