Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-12-2008, 05:08 PM
Member
 
Join Date: Jul 2008
Posts: 3
hemant is on a distinguished road
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..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-12-2008, 09:23 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 780
Nicholas Jordan is on a distinguished road
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
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-12-2008, 11:03 PM
Member
 
Join Date: Jul 2008
Posts: 3
hemant is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-13-2008, 01:57 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-13-2008, 06:57 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 475
fishtoprecords is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-13-2008, 06:58 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 780
Nicholas Jordan is on a distinguished road
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.
Quote:
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-13-2008, 08:28 PM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 475
fishtoprecords is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JBatchUpload - Queue files before upload jfileupload Java Announcements 0 07-06-2008 04:00 PM
Queue data structure Java Tip java.lang 0 04-14-2008 10:35 PM
Declaring a Queue rhm54 New To Java 1 03-21-2008 07:02 AM
Help with queue array please!! vmcg105 New To Java 1 03-08-2008 09:03 PM
Using a queue Krmeus New To Java 0 12-10-2007 05:38 PM


All times are GMT +3. The time now is 12:35 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org