Reading data error [multiplayer bluetooth game]

Forum for discussion about developing multiplayer games for mobile platform including Httpconnection and bluetooth connections.

Reading data error [multiplayer bluetooth game]

Postby itskrishnaraj » Tue Nov 25, 2008 9:26 am

hi

i am sending a byte array value through stream connection in my multiplayer game. i can able to send it successfully but i can't read the values which i have sent. it showing some exceptions

*****************Exception while executing***************
java.io.IOException: error 10054 during TCP read

java.lang.NullPointerException



********************Read data code***********************

public static byte[] readData(StreamConnection conn)
{
System.out.println("enter into readData");
input = null;
byte[] data = null;
StringBuffer bufferVal = new StringBuffer();
int ch;
int size = 0;

try
{
System.out.println("before openInputStream");

input = conn.openInputStream();

System.out.println("input>>>>>>>>>> "+input);
System.out.println("after openInputStream");

while ( ( ch = input.read() ) != -1 )
{

bufferVal.append( (char) ch );
size++;
System.out.println("inside while");
}
System.out.println( "Receive Datas " );
data=new byte[size];
data = bufferVal.toString().getBytes();

for(int m=0;m<data.length;m++)
{
System.out.println("Receive Datas---> "+data[m]);
}

}
catch (IOException ioe)
{
System.err.println(ioe);
}
finally
{
close input stream
if (input != null)
{
try
{
input.close();
}
catch (IOException e)
{

}
}
}
return data;
}

thanks in advance
itskrishnaraj
 
Posts: 39
Joined: Thu Aug 07, 2008 1:28 pm

Return to Multiplayer Mobile Games

Who is online

Users browsing this forum: No registered users and 1 guest

cron