On Mon, 13 Mar 2006 09:25:44 -0800 Rick Jones <[EMAIL PROTECTED]> wrote:
> Eric Molitor wrote: > > You are correct, the format is as follows. > > > > Command Packet > > * Header > > o length (4 bytes) > > o id (4 bytes) > > o flags (1 byte) > > o command set (1 byte) > > o command (1 byte) > > * data (Variable) > > > > Reply Packet > > * Header > > o length (4 bytes) > > o id (4 bytes) > > o flags (1 byte) > > o error code (2 bytes) > > * data (Variable) > > > > Source: http://java.sun.com/j2se/1.4.2/docs/guide/jpda/jdwp-spec.html > > Also maybe useful: > > http://java.sun.com/j2se/1.5.0/docs/guide/jpda/socketTransport-example.c > > Soooo, since they know the length it means they know the data to send, > which means there is no valid excuse for not sending all the data at one > time - ie in one call to the transport. Their use of TCP_NODELAY was > simply a kludge, and a massive one at that. > > I still think there are issues trying to map the byte-based RFC cwnds to > a packet based cwnd in the stack, but the application is defintely broken. > Even doing it two pieces (header and data) would have worked. --- socketTransport-example.c.orig 2006-03-13 10:14:00.000000000 -0800 +++ socketTransport-example.c 2006-03-13 10:24:02.000000000 -0800 @@ -445,7 +445,16 @@ static jdwpTransportError JNICALL socketTransport_writePacket(jdwpTransportEnv* env, const jdwpPacket *packet) { - jint len, data_len, id; +#pragma pack + struct { + jint len; + jint id; + jbyte flags; + union { + jshort errorCode; + jbyte cmd[2]; + }; + } header; jbyte *data; /* packet can't be null */ @@ -453,7 +462,6 @@ RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "packet is NULL"); } - len = packet->type.cmd.len; /* includes header */ data_len = len - 11; /* bad packet */ @@ -461,40 +469,22 @@ RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "invalid length"); } - len = (jint)dbgsysHostToNetworkLong(len); - - if (dbgsysSend(socketFD,(char *)&len,sizeof(jint),0) != sizeof(jint)) { - RETURN_IO_ERROR("send failed"); - } - - id = (jint)dbgsysHostToNetworkLong(packet->type.cmd.id); - - if (dbgsysSend(socketFD,(char *)&(id),sizeof(jint),0) != sizeof(jint)) { - RETURN_IO_ERROR("send failed"); - } - - if (dbgsysSend(socketFD,(char *)&(packet->type.cmd.flags) - ,sizeof(jbyte),0) != sizeof(jbyte)) { - RETURN_IO_ERROR("send failed"); - } + header.len = (jint)dbgsysHostToNetworkLong(packet->type.cmd.len); + header.id = (jint)dbgsysHostToNetworkLong(packet->type.cmd.id); + header.flags = packet->type.cmd.flags; if (packet->type.cmd.flags & JDWPTRANSPORT_FLAGS_REPLY) { - jshort errorCode = dbgsysHostToNetworkShort(packet->type.reply.errorCode); - if (dbgsysSend(socketFD,(char *)&(errorCode) - ,sizeof(jshort),0) != sizeof(jshort)) { - RETURN_IO_ERROR("send failed"); - } + header.errorCode = dbgsysHostToNetworkShort(packet->type.reply.errorCode); } else { - if (dbgsysSend(socketFD,(char *)&(packet->type.cmd.cmdSet) - ,sizeof(jbyte),0) != sizeof(jbyte)) { - RETURN_IO_ERROR("send failed"); - } - if (dbgsysSend(socketFD,(char *)&(packet->type.cmd.cmd) - ,sizeof(jbyte),0) != sizeof(jbyte)) { - RETURN_IO_ERROR("send failed"); - } + header.cmd[0] = packet->type.cmd.cmdSet; + header.cmd[1] = packet->type.cmd.cmd; } - + + if (dbgsysSend(socketFD,(char *)&header, sizeof(header), 0) + != sizeof(header)) { + RETURN_IO_ERROR("send failed"); + } + data = packet->type.cmd.data; if (dbgsysSend(socketFD,(char *)data,data_len,0) != data_len) { RETURN_IO_ERROR("send failed"); - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html