Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Urgent PLZ help - communication between server and mobile

Status
Not open for further replies.

rainwhisper

Newbie level 3
Joined
Oct 27, 2008
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,318
Urgent PLZ help

Hi all,

hope all fine and every thing go good with you.

i went to build application that need communication between server and mobile. the mobile send data to the server successfully but the mobile doesn't receive data from server although i open data input stream. i build another client using C# to be sure that the problem from the server or mobile and i found that the server is ok. ..... really i don't know what is the problem can any body help me

and this is my connection code

public void connection() throws IOException
{
HttpConnection conn = null;

String url = "http://www.myserver.com/test.txt";
DataInputStream dis = null;
DataOutputStream dos = null;
try
{
conn = (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
conn.setRequestMethod(conn.POST);
conn.setRequestProperty("Content-Type", "//text plain");
conn.setRequestProperty("Content-Language", "en-US");
String username = loginScreen.getUsername();
String password = loginScreen.getPassword();
String send = "username : " + username + "password : " + password
dos = conn.openDataOutputStream();
dos.write(send.getBytes());
dos.flush();

int res_code = conn.getResponseCode();
if(res_code != HttpConnection.HTTP_OK)
{
throw new IOException ("fail to connect to the server");
}
dis = conn.openDataInputStream();
int length = (int) conn.getLength();
if (length > 0)
{
int actual = 0;
int bytes_read = 0;
byte[] data = new byte [length];
while ((bytes_read != length)&& (actual != -1))
{
actual = dis.read(data, bytes_read, length - bytes_read);
bytes_read += actual;
}
}


} // end of try

catch (IOException error)
{
System.out.println("caught IO exception" );;
}
finally
{
if (dis != null)
dis.close();

if (dos != null)
dos.close();

if (conn != null)
conn.close();
}

}


thanks in advance,
 

Re: Urgent PLZ help

sory dear i have read ur problem but i dont understand it and may be i cant reply you after understanding it.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top