Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / September 2005

Tip: Looking for answers? Try searching our database.

about the peek methods of DatagramSocketImpl

Thread view: 
Pavlos Georgiadis - 22 Sep 2005 15:00 GMT
The abstract class DatagramSocketImpl has two methods.
int peek(InetAddress)
and
int peek(DatagramPacket)

Does anyone know what exactly this methods do? What are they for?

I can't find any documentation about them. The javadoc says:
for the first
Peek at the packet to see who it is from.
for the second
Peek at the packet to see who it is from. The data is returned, but not
consumed, so that a subsequent peekData/receive operation will see the
same data.

So they peek a look at the first available received packet of a socket
but leave it there to be received from the Application that uses the
DatagramSocket.

I managed to find that the integer that tey return is the source port of
the received datagram.

But, for the first method, how does it return the InetAddress of the
sender of the packet? The InetAddress class does not provide any set
methods. The same for the second method. How does it return the datagram?
Boudewijn Dijkstra - 25 Sep 2005 17:52 GMT
> The abstract class DatagramSocketImpl has two methods.
> int peek(InetAddress)
> and
> int peek(DatagramPacket)

That should read
int peekData(DatagramPacket)

> Does anyone know what exactly this methods do? What are they for?
>
[quoted text clipped - 5 lines]
> consumed, so that a subsequent peekData/receive operation will see the same
> data.

So you could find some documentation.

> So they peek a look at the first available received packet of a socket but
> leave it there to be received from the Application that uses the
> DatagramSocket.

I suppose so.

> I managed to find that the integer that tey return is the source port of the
> received datagram.

Well, there you have it.

> But, for the first method, how does it return the InetAddress of the sender
> of the packet? The InetAddress class does not provide any set methods. The
> same for the second method. How does it return the datagram?

It doesn't return an InetAddress, it returns an int, just like the second
method.  Supposedly, the first method looks up the last packet received from
the specified address and returns it's source port.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.