Results 1 to 7 of 7
  1. #1
    hemant is offline Member
    Join Date
    Jul 2008
    Posts
    3
    Rep Power
    0

    Thumbs up queue length of Socket

    hi all.

    i am sending data packets from my server to client. those packets come and queue up at client DatagramSocket when they're received . so i can't find out exact time they arrived. also i don't know present queue length..

    any ideas..

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Queue lenght is somewhat system dependent. It is supposed to be 65k or so but is often truncaked to around 40k by network traffic routers. Time of arrival would be implemented by a call to get system time early in DatagramSocket (Java 2 Platform SE 5.0))

    this gets threading issues on the board, the thread that runs in rcv is new'ed by the system == if two datagram arrive at the same time calling sys time can result in packet n getting pancaked with packet n+1
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    hemant is offline Member
    Join Date
    Jul 2008
    Posts
    3
    Rep Power
    0

    Default

    thanks for reply. but i didn't get this that when i get a packet i proceed to process the packet and then use its byte array to display an image. so only after a certain time i'll return to rcv meanwhile packets would have kept on queuing . so i cannot know their exact time?
    can you suggest any way that i should interuupt my current thread whenever a packet comes to save it in a byte arr.
    but this'll waste a lot of time.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    You could start another thread that polled for new input and read it into a queue for later processing.
    Are there methods in the DatagramSocket class that will block until there is input to read? Put that in a loop and read whenever something comes in and queue it for processing by another thread.

    Still don't know how to get EXACT time of arrival. Best would be when you first saw it.

  5. #5
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    As @norm says, you can know pretty well when you processed it, and have a lightweight process that gets the data out of the socket and into an internal queue quickly. But you can *not* know when it arrived with any precision.

    Its hard for me to think of a real reason why you would care. For auditing, or logging, you can just get the time you put it in the queue and call that good enough.

  6. #6
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Post Pancake, a new type of Stack

    Quote Originally Posted by hemant View Post
    ... after a certain time i'll return to rcv meanwhile packets would have kept on queuing . so i cannot know their exact time?
    The way to approach this is a short, and I mean really short, code block snuggled up on accept, that .... ....? Why is this so important -> you are trying to correctly identifiy traffic so that requests can be grouped together? Session tracking, logging? There is some goal you are trying to attain that can be put into words. If not, you are trying to do systems work and that can end up with a cross-lock.
    can you suggest any way that i should interuupt my current thread whenever a packet comes to save it in a byte array?... but this'll waste a lot of ( processor power ).
    Send and receive run almost asynchronously, and are programmed at a level below Java. I am writing right now what I think you are trying to do. You likely want a SessionMaster object that can keep things organized. What happens if someone clicks the button twice accidenatlly?... happens all the time.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  7. #7
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by hemant View Post
    can you suggest any way that i should interuupt my current thread whenever a packet comes to save it in a byte arr. but this'll waste a lot of time.
    Why would it waste time? You have to read from the socket and put the data in an array no matter when you do it.

    You use multiple threads, Java has had them since 1.0. Its designed to have you do it this way.

    You use a java.util.concurrent.CyclicBarrier or a similar object to coordinate.

Similar Threads

  1. JBatchUpload - Queue files before upload
    By jfileupload in forum Java Software
    Replies: 0
    Last Post: 07-06-2008, 03:00 PM
  2. Queue data structure
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:35 PM
  3. Declaring a Queue
    By rhm54 in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 06:02 AM
  4. Help with queue array please!!
    By vmcg105 in forum New To Java
    Replies: 1
    Last Post: 03-08-2008, 08:03 PM
  5. Using a queue
    By Krmeus in forum New To Java
    Replies: 0
    Last Post: 12-10-2007, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •