Sending bytes issue

Hi

I am implementing an echo server and a client to measure RTT and throughput of a TCP link. I have been provided with a detailed protocol the server and client must follow.

Here is the problem:

The server at a certain point will be waiting for the client to send data in the following format <'m'><space><sequence #><space><payload>. The payload will have to be either 1, 100, 200, 400, 800, and 1000 Bytes.

Since I've implemented the server and the client both to read and write strings/characters to each other, I dont know how to send and receive the payload part of the message with a desired size.

Any idea how I can send and parse a desired number of bytes in/from a message (a string message)?

Although I know that a character is encoded as 2 bytes, but what do I do about this 1 byte? would I need to recode my client and server to work with byte streams?

Thanks

Message was edited by:

eXKoR

[996 byte] By [eXKoRa] at [2007-11-26 18:58:08]
# 1
ok I've found this: http://forum.java.sun.com/thread.jspa?threadID=745736&messageID=4268996
eXKoRa at 2007-7-9 20:38:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Ok now I know how to send 1 byte but I still dont want to recode my server and client sending and parsing ALL messages as bytes.

How would I go about sending the first part of the message as characters and the payload as byte[] and being able to break this message into the correct pieces at the server end?

Thanks

eXKoRa at 2007-7-9 20:38:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Send two messages? One containing your text content and the second containing the raw bytes for your payload.Whatever the solution, it probably involves some code reworking.
gimbal2a at 2007-7-9 20:38:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...