Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Sockets and TCP packets

  1. #1
    Junior Member
    Join Date
    May 2012
    Thanked 0 Times in 0 Posts

    Default Sockets and TCP packets

    Hi, have this question: I can easily communicate between two java sides using sockets, buffers and write() and readLine() functions. But now i have java server and agreement with the other side about how will TCP packet payload look like (4 bytes of length of data, 1 byte function number, 0-100 bytes of actual data). I have byte[105] variable and my question is... are sockets still usable? I.e. will be my out buffer packed into one TCP packet data payload when I use sockets? The other side is not java based and only listen for TCP packets. If i can't use sockets, can you point me the right direction?


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Tavistock, UK
    Thanked 103 Times in 93 Posts

    Default Re: Sockets and TCP packets

    Quote Originally Posted by Raadush View Post
    will be my out buffer packed into one TCP packet data payload when I use sockets?
    I doubt it would be impossible to assert this from any language, and doubt that it matters - who programs applications at that level? I would just try a Java Socket test program and see how it goes. Your remote end should see only a stream of bytes, so it shouldn't matter whether the underlying packets are fragmented or not.

Similar Threads

  1. Sockets in JApplet
    By shrey.haria in forum Java Networking
    Replies: 4
    Last Post: September 5th, 2011, 09:45 AM
  2. [SOLVED] Problems with Sockets
    By Samthere in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 21st, 2011, 06:02 AM
  3. Some information on retrieving packets
    By Cheetah in forum Java Networking
    Replies: 0
    Last Post: July 11th, 2010, 08:43 PM
  4. Packets
    By TheEnd in forum Java Networking
    Replies: 1
    Last Post: February 19th, 2010, 04:16 AM
  5. Packets Sent
    By TheEnd in forum Java Theory & Questions
    Replies: 0
    Last Post: January 23rd, 2010, 09:29 AM