• Post Reply Bookmark Topic Watch Topic
  • New Topic

About header  RSS feed

 
fei long
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i have a simple question about headers such as tcp, ip, or whatever. My question is how can i define 8 bytes or 16 bytes using java. In other words, how do i define headers? use string or byte array or something? Can anyone give a sample code?
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know whether i understood your question correctly or not. What i understood is you are trying to define or set headers and probably would be writing them through a stream . If that's what you wanted to know , then yes you can do that by storing the hearder information into Strings and write them through a DataoutputStream or if you want to converrt the headers into bytes then us the getBytes() method and send the header via BufferedOutputStream.
Hope this helps !
Originally posted by ordin sword:
Hi, i have a simple question about headers such as tcp, ip, or whatever. My question is how can i define 8 bytes or 16 bytes using java. In other words, how do i define headers? use string or byte array or something? Can anyone give a sample code?
 
fei long
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, that's exactly what i want to ask.
But the problem is how can i set the length of each field. I mean say if i want to assign 4 bytes to source address, 1 bytes to type field, and so on. How can i achieve this? If i use string i can just have ("201.15.21.181" + "1") like this. Do you know what i mean?
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ordin sword:
Do you know what i mean?

confused
 
fei long
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply say, if i want to write a header which has three fields, such that: address field, type field, and length field. And I want to make address field 4 bytes, type field 1 bytes, and length field 2 bytes. How can i write this in java?
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to send headers the way they are . That's all i can tell you . I don't what would achieve by doing what you are trying to but if you are sending headers then send them the way they are .
Hope this helps.
Originally posted by ordin sword:
Simply say, if i want to write a header which has three fields, such that: address field, type field, and length field. And I want to make address field 4 bytes, type field 1 bytes, and length field 2 bytes. How can i write this in java?

[ November 19, 2002: Message edited by: raghav mathur ]
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See DataOutputStream.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!