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
