Im writing an application to send data to/from mobile to pc.
Im a little stuck when trying to actually send data from the mobile(J2ME) to the pc(J2ME).
Im not sure what im doing wrong, but im getting the error
java.io.StreamCorruptedException: invalid stream header
on the server(J2SE) side every time.
The client (J2ME) code is
//create connection to server
StreamConnection connection = (StreamConnection) Connector.open("socket://localhost:2000", Connector.READ_WRITE);
//build streams
DataOutputStream os = connection.openDataOutputStream();
//write data
int t = 100;
os.writeInt(t.toString());
os.flush();
...
The server (J2SE) is
ServerSocket serverSocket = new ServerSocket(2000); Socket client = serverSocket.accept(); ObjectInputStream serverInputStream = new ObjectInputStream(client.getInputStream()); int height = serverInputStream.readInt();
Can anyone see what im doing wrong?
Thanks,
Chris.

Ask A New Question
Reply





MultiQuote





|