aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes how to develope tcp protocol in socket connetion Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "how to develope tcp protocol in socket connetion" Watch "how to develope tcp protocol in socket connetion" New topic
Author

how to develope tcp protocol in socket connetion

Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 151
|---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


Judge a man by his questions rather than his answers --Voltaire
SCJP 1.5 97%
Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
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 Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 151
can we send as packet using tcp connection like udp serverpacket.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35232
    
    7
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.


Android appsImageJ pluginsJava web charts
Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 151
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
Marshal

Joined: Jul 08, 2003
Posts: 24048
    
  13

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.


[Jess in Action][AskingGoodQuestions]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4422
    
    2

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to develope tcp protocol in socket connetion
 
Similar Threads
UDP Packet Reassembly
online multiplayer snake game: packet overhead
Java Security MOCK
file transfer using datagram
IP/host filtering in log files?