Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-21-2005, 06:22 PM   #1 (permalink)
Albeeezz
Registered User
 
Join Date: May 2005
Posts: 5
Albeeezz is on a distinguished road
Question bytes sent / recieved ?

Hello,

I am a newbie programmer and I was wondering how i can "listen" to ports on my pc and read the bytes sent and recieved, very much like in windows how you double click on the "connection status" in the lower-right hand corner of the screen.

I have been told that the java.net* package can be used for this type of thing.

Can anyone please tell me the classes and methods involved in listening to, and getting the size of any incoming and outgoing packets?




Your help is greatly appreciated,


Albeeezz
Albeeezz is offline   Reply With Quote
Old 06-22-2005, 01:50 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,139
Belisarius is on a distinguished road
While you can keep track of bits going out over a connection (as in a TCP connection), I'm not sure how you'd keep track of data going out over a *device* like Windows does (that strikes me as an OS level operation that's out of the scope of Java). You might be able to do it, but I honestly don't have a clue how.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 06-22-2005, 10:46 AM   #3 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
Take at look at datagrams. Specificially, there is a DatagramSocket class. There is also a DatagramPacket class. The DatagramPacket has methods for setting the size of a packet for packets sent (outgoing). To receive packets, you have to specify the maximum allowed packet size. You'd have to write the specifics for tracking total bytes received for example, but it should be easily done based on the methods available (e.g. getlength(), getData() ). The problem with datagrams is that they do not guarantee delivery. Packets can arrive out of sequence or not at all.

Good luck! A google search on java.net DatagramPacket should give you more details.
Here's a good place to start: http://java.sun.com/j2se/1.4.2/docs/...ramPacket.html
__________________
It takes 2 points to draw a straight line, but at least 3 points to draw a conclusion.
technobard is offline   Reply With Quote
Reply

Bookmarks

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

BB 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
Splitting Bytes in C sde Standard C, C++ 7 05-26-2004 03:24 PM


All times are GMT -8. The time now is 05:36 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting