Implementing C language TCP header using Java
Hello,
I am in need of implementing the following C language code under Java...
{
short len;
struct
{
char trans_id[4];
char trans_filler[46];
char data_vector[2];
char data_len[2];
} tcp_hdr;
len = 257;
memcpy(&tcp_hdr.trans_id[0],"SURV", 4);
memset(&tcp_hdr.trans_filler[0], NULL, sizeof(tcp_hdr.trans_filler);
tcp_hdr.data_vector[0] = 0x00;
tcp_hdr.data_vector[1] = 0x08;
memcpy(&tcp.hdr.data_len[0], &len, 2);
}
The code is used to create a TCP header that is prefixed on all Socket messages sent to the host.
I thought I would throw this out and see if anyone has any ideas on how to implement this...
Thanks.
-Jeff
[1058 byte] By [
k0balta] at [2007-11-27 5:09:29]

# 1
> Hello,
>
> I am in need of implementing the following C language
> code under Java...
>
> > {
>short len;
> struct
>{
>char trans_id[4];
>char trans_filler[46];
>char data_vector[2];
>char data_len[2];
> } tcp_hdr;
>
>len = 257;
>memcpy(&tcp_hdr.trans_id[0], "SURV", 4);
> memset(&tcp_hdr.trans_filler[0], NULL,
> sizeof(tcp_hdr.trans_filler);
>tcp_hdr.data_vector[0] = 0x00;
> tcp_hdr.data_vector[1] = 0x08;
>memcpy(&tcp.hdr.data_len[0], &len, 2);
>
>
>
> The code is used to create a TCP header that is
> prefixed on all Socket messages sent to the host.
>
> I thought I would throw this out and see if anyone
> has any ideas on how to implement this...
>
> Thanks.
>
> -Jeff
What is the problem? You can write an identical header in many different ways. One is to use DataOutputStream.
Kaj
kajbja at 2007-7-12 10:29:14 >
