I'm running into a problem with sending packets between a java client and a c++ server over a tcp/ip socket.

the data being sent between the client and server is a plain text string.

the problem I'm having is the java client can send packets to the server and the server can process the strings send without a problem. However, when I send a string from the server to the client the java client either interprets it as being a blank string or as random characters.

here's the relevant c server code

Here's how I setup the buffer
Code:
char* messageBuf = (char*)malloc(sizeof(char)*1025);
Here's an example of the first thing I try to write from the server to the client and how I put it into the buffer.
Code:
messageBuf[0]='?';
messageBuf[1]='\0';
Here's the function call I use to send the packet through the socket
Code:
if(send(cfd->connection,messageBuf,strlen(messageBuf),0)<0){
        perror("Server: write error");
        cfd->~clientConnection();
        close(cfd->connection);
        delete cfd;
        return(0);
    }
here's the relevant java client code

I setup my socket in java with
Code:
s = new Socket("127.0.0.1", serverPort);
setup my input output streams in java with
Code:
DataOutputStream out =	new DataOutputStream(s.getOutputStream());
DataInputStream in = new DataInputStream(s.getInputStream());
read from the stream in java using
Code:
char bytes[] = new char[1025];
                    String data;
                    in.read(bytes);
                    data = bytes.toString();
any help would be very much appreciated.