• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how to develope tcp protocol in socket connetion

 
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
 
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.
 
Rancher
Posts: 43016
76
  • 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
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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.
 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • 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
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic