Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to develope tcp protocol in socket connetion  RSS feed

 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
|---0-7------------------------|----8-11----------------|-------12-15----------|

Packet Length Setting/Used Encryption Settings/Not Reserved
for Error Notification used after first header
after first header

Current Packets Length (LSB) Current Packets Length (MSB)

--------------------------------------------------------------------------------

i want to design this packet and sent it to server with proper acknowledgment

how to design this packet using tcp please suggest me
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not really clear as to what you looking for. However here is my best attempt.

Write a class with as many attributes as there in the payload and add methods to convert the values of individual attributes to byte array.

Send the bytearray over normal Socket to the server and server should be able to decode and use the payload.

If this doesn't give any hint, please repharse in detail what you want to do and where you are stuck.
 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we send as packet using tcp connection like udp serverpacket.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure either what you're asking. You can send anything you want over a TCP connection. See e147 - e151 here for examples.

What do you mean by "serverpacket"? UDP is used to send datagrams.
 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my client server application i am going to use java.nio because its supporting 10k client at a time and more performance.i used tcp connection with i want to sent as packet.using udp we can send as a packet(DatagramPacket) in tcp connection how can we send as a packet else we would send ByteArray as a packet.

how to design packet in tcp connection.

another problem in server side is i am using nio with non blocking.so if the client sent as packet even though the nonblocking server will wait to receive
full packet its get whatever received from the stream.in this situation how can i solve this problem...
please suggest me
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TCP doesn't work like UDP. You can't send discrete "packets", but only write to a continuous stream of data (underneath, of course, the TCP stack breaks the stream into packets for delivery, but Java doesn't give you any access to that.)

Anyway, I think you probably need to do some basic reading on networking technologies before you go designing this application. You need to understand your terminology better and understand what's possible.
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As others have said, you are missing some basics.

Java's nio is a great idea, but its far more difficult to use well than it should. If you really want to use it, I suggest you look at the Apache
Mina framework
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!