Read byte to lan

Hi,
I would like to read the number of bytes sent and received on a specific lan connection? I would like to create a simple network monitor.
but I could not find anything.
Can you help me?
I tried to parse the netstat-e but the bytes are not specific to a connection, and totaly bytes are not congruent with connection status windows.
Attached connection status windows and netstat
Solved!
Go to Solution.
Attachments:
Windows Stat.jpg ‏55 KB
netstat.jpg ‏49 KB

If you're a windows user, you could use this.
https://decibel.ni.com/content/docs/DOC-1089
Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.
"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Similar Messages

  • SocketInputStream.read(byte[], int, int) extremely slow

    Hi everyone,
    I'm trying to send several commands to a server and for each command read one or more lines as response. To do that I'm using a good old Socket connection. I'm reading the response lines with BufferedReader.readLine, but it's very slow. VisualVM says, that SocketInputStream.read(byte[], int, int) is consuming most of the cpu time. A perl script, which does the same job, finishes in no time. So it's not a problem with the server.
    I'm runnning java version "1.6.0_12"
    Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
    Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode) on Linux henni 2.6.25-gentoo-r7 #3 SMP PREEMPT Sat Jul 26 19:35:54 CEST 2008 i686 Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz GenuineIntel GNU/Linux and here's my code
    private List<Response> readResponse() throws IOException {
            List<Response> responses = new ArrayList<Response>();
            String line = "";
            while ( (line = in.readLine()) != null) {
                int code = -1;
                try {
                    code = Integer.parseInt(line.substring(0, 3));
                    line = line.substring(4);
                } catch (Exception e) {
                    code = -1;
                // TODO create different response objects ?!?
                NotImplemented res = new NotImplemented(code, line);
                responses.add(res);
                // we received an "end of response" line and can stop reading from the socket
                if(code >= 200 && code < 300) {
                    break;
            return responses;
        }Any hints are appreciated.
    Best regards,
    Henrik

    Though it's almost an sscce I posted there, I will try to shrink it a little bit:
    Dummy server:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class Server {
        public Server() throws IOException {
            ServerSocket ss = new ServerSocket(2011);
            Socket sock = ss.accept();
            BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
            PrintStream ps = new PrintStream(sock.getOutputStream());
            ps.println("200 Welcome on the dummy server");
            String line = "";
            while(line != null) {
                line = br.readLine();
                ps.println("200 Ready.");
        public static void main(String[] args) throws IOException {
            new Server();
    }the client:
    import java.io.IOException;
    import java.io.PrintStream;
    import java.net.InetSocketAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.util.Scanner;
    import de.berlios.vch.Config;
    public class Client {
        private Socket socket;
        private PrintStream out;
        private Scanner scanner;
        public Client(String host, int port, int timeout, String encoding)
            throws UnknownHostException, IOException {
            socket = new Socket();
            InetSocketAddress sa = new InetSocketAddress(host, port);
            socket.connect(sa, timeout);
            out = new PrintStream(socket.getOutputStream(), true, encoding);
            scanner = new Scanner(socket.getInputStream(), encoding);
        public synchronized void send(String cmd) throws IOException {
            // send command to server
            out.println(cmd);
            // read response lines
            readResponse();
        public void readResponse() throws IOException {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                System.out.println(line);
                int code = -1;
                try {
                    code = Integer.parseInt(line.substring(0, 3));
                    line = line.substring(4);
                } catch (Exception e) {
                    code = -1;
                if (code >= 200 && code < 300) {
                    break;
        public static void main(String[] args) {
            try {
                Client con = new Client("localhost", 2011, 500, "utf-8");
                con.readResponse();
                con.send("version 0.1");
                con.send("menu = new menu Feeds");
                con.send("menu.EnableEvent close");
                con.send("menu.SetColorKeyText -red 'Öffnen'");
                for (int i = 0; i < 100; i++) {
                    String groupId = "group"+i;
                    long start = System.currentTimeMillis();
                    con.send(groupId+" = menu.AddNew OsdItem '"+groupId+"'");
                    con.send(groupId+".EnableEvent keyOk keyRed");
                    long stop = System.currentTimeMillis();
                    System.out.println((stop-start)+"ms");
            } catch (Exception e) {
                e.printStackTrace();
    }This code makes me believe, it's not a java problem, but some system setting of my os.

  • How to do it?  Alternate readLine(), read bytes?

    Problem: How to alternate between an InputStreamReader and a raw InputStream when reading data from an InputStream. The catch is that the InputStreamReader may read ahead a few bytes and so subsequent reading from the underlying InputStream will miss those buffered bytes.
    Background:
    I have an application that communicates with a Tomcat servlet with Http protocol.
    I want to send a request, and receive a response as a Java Object. The problem is receiving the response as a Java Object.
    Actually, I have no problem if I use a URLConnection and create an ObjectInputStream from the URLConnection InputStream. But the URLConnection is very slow to use for uploading large files.
    There is a code project called JUpload which uploads files very fast, at least 10 times as fast as URLConnection. It uses sockets and their input/output streams. So I'm adapting some of that code for my application.
    The problem is that the JUpload code is harder to use. It parses the HTTP headers in both directions. When receiving the response, it parses the HTTP headers using an InputStreamReader wrapped in a BufferedReader to read lines, and continues reading lines for any other responses destined to the application.
    However, I need to read a Java object after the header. Therefore, I need to get the underlying InputStream so I can create my ObjectInputStream.
    There is a conflict here. The BufferedReader may (and does) read ahead, so I can't get a "clean" InputStream.
    I have a workaround, but I'm hoping there is a better way. It is this: After reading the HTTP header lines, I read all the remaining characters from the BufferedReader and write them to a ByteArrayOutputStream wrapped in an OutputStreamWriter. Then I create a new ByteArrayInputStream by getting the bytes from the ByteArrayOutputStream. I then "wrap" my ObjectInputStream around the ByteArrayInputStream, and I can read my Java Object as a response.
    This technique is not only clumsy, but it requires buffering everything in memory after the header lines are processed (which happens to be OK for now as my response Object is not large). It also gets really clumsy if the returned HTTP reponse is chunked, because the BufferedReader is needed alternately to read the chunk headers. Fortunately, I haven't encountered a chunked response.
    It feels like what I need is a special Reader object that allows you to alternately read characters or read bytes without "stuttering" (missing buffered bytes).
    I would think the authors of the URLConnection would have encountered this same problem.
    Any thoughts on this would be appreciated.
    -SB
    Edited by: SB4 on Mar 21, 2010 8:08 PM
    Edited by: SB4 on Mar 21, 2010 8:09 PM
    Edited by: SB4 on Mar 21, 2010 8:10 PM

    Yes, that is the problem as you noted. My solution is to continue reading all the characters from the BufferedReader and to convert them back to a byte stream using the ByteArrayOutputStream, OutputStreamWriter, etc.
    It works, just seems clumsy and not scalable.
    I was hoping there might exist a special "CharByteReader" (invented name) class somewhere that would be like a BufferedReader, but that would implement a read(byte[], offset, length) type of method that could access the read-ahead buffer in the same way the read(char[], offset, length) method does.
    URLConnection is just too slow, including chunked mode.

  • GetResourceAsStream problems Read(byte[])

    Heres my code. Some images show up fine, others dont show up at all, and others show up as black images when the images are in a jar file. All images show up fine when they are on the lcoal file system. All images DO fit in the ~60kb byte array. Any suggestions on what the problem is, I have worked around my problem but I would like to know what was going on. My work around was to loop inputstream.read() into the byte array and that has worked.
        public static ImageIcon GetImage(String fileName)
            InputStream iStream=null;
            ImageIcon ic = null;
            try
                if( classLoader == null )
                    try
                        classLoader = Class.forName( "myappclass" ).getClassLoader();
                    catch( Exception x)
                        System.out.println( x.toString() );
                        return ic;
                iStream = classLoader.getResourceAsStream( fileName );
                byte[] bytes = new byte[65000];
                iStream.read(bytes);
               //heres around where it goes caplooyey
                ic = new ImageIcon(bytes);
            catch (IOException ex)
    //            iStream.close();
                System.out.println("No existing file to copy");
                return ic;
            return ic;
        }

    Your code is reading the stream before all the data are available so one read will grab only a partial image. One solution would be to use a BufferedInputStream, but that would consume even more memory than your current approach.
    A much simpler, more efficient, and wholly equivalent technique is accomplished with this one line of code:
    ic = new ImageIcon(ClassLoader.getSystemResource(fileName));

  • After i reading bytes ,how do i get the image to display?

    After i reading bytes ,how do i get the image to display?
    i m lost after tis step:
    Image img=Toolkit.getDefaultToolkit().createImage(data1);

    You can create and use a Canvas. (and define the Paint method)
    Canvas c = new Canvas(){
            public void paint(Graphics g){
                g.drawImage(img,0,0,this);
    frame.add(c);

  • Need info about DataInputStream - read (byte[] ) method

    Hi all,
    I would like to know when does
    datainputStream.read(byte[] buffer) method return?
    Here dataInputStream is an object of type DataInputStream.
    Does the method return only after buffer.length bytes are read from the input stream? or Will it return after some bytes are read , even if the number of bytes read is less than buffer.length?
    I need this info because while developing a J2ME application and running it in an emulator , the above method seems to return even if some bytes are read.But when the application is transferred to a Mobile device, the method does not seem to return if some bytes are read, and seems to wait until buffer.length is reached.

    one more?

  • Read byte from a long

    Hi,
    How can I read bytes from a long. i..e read one byte by one byte from long.
    Naman Patel

    ok here is my problem how do i ignore the sign byte i.e please check this code
    long nr=1345345333L, add=7, nr2=0x12345671L;
              long tmp;
              long[] result = new long[2];
              char[] pwd = password.toCharArray();
              for (int pCount = 0; pCount < pwd.length; pCount++){
                   if (pwd[pCount] == ' ' || pwd[pCount] == '\t')
                        continue;
                   tmp= (long) pwd[pCount];
                   nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
                   nr2+=(nr2 << 8) ^ nr;
                   add+=tmp;
              result[0]=nr & (((long) 1L << 31) -1L); /* Don't use sign bit (str2int) */;
              result[1]=nr2 & (((long) 1L << 31) -1L);
              int i = 0;
              long x = result[0];
              byte b[] = longToBytes(x);
              String str = "";
              i = 0;
              while(i < 4){
                   if(b[i] == 0x00) {
                        System.out.println("byte is 0x00");
                        str += "00";
                   else {
                        if(b[i] <= 0x0f && b[i] >= 0) {
                             System.out.println("byte is 0x0f" + b);
                             str += "0";
                        break;
                   i++;
              i = 0;
              str += Long.toHexString(result[0]);
              x = result[1];
              b = longToBytes(x);
              while(i < 4){
                   if(b[i] == 0x00) {
                        System.out.println("byte is 0x00");
                        str += "00";
                   else {
                        if(b[i] <= 0x0f && b[i] >= 0) {
                             System.out.println("byte is 0x0f");
                             str += "0";
                        break;
                   i++;
              str += Long.toHexString(result[1]);

  • Read byte by byte

    Hi. I'm using the module "bytes at serial port" to read the answers of my robot, but i do not want to read all bytes at the same time. I want to read byte by byte. How can i do it?
    Thanks.
    Ivan.

    So it seems as if ">" is the character that signals the termination of a command.  Use this as your termination character, and initialize the serial port that way.  See picture of how to do this (">" is ASCII 62 in decimal).  When reading, the ">" character will signal the termination and the reading will stop.  Other characters afterwards will remain in the buffer until the next read.
    You should fix your code to prevent infinite loops in case the termination character is not received.  What happens if the character is never sent due to some glitch in the sending system, or if some glitch causes a different character to be received instead of ">", or if the comm link breaks before ">" is received?  Your program will get stuck.  You need to fix this by putting a timeout or something that will abort or end the code in case something goes wrong.
    Message Edited by tbob on 06-12-2006 10:25 AM
    - tbob
    Inventor of the WORM Global
    Attachments:
    Term.png ‏1 KB

  • Issue with reading byte array

    I have a binary file to be read.I want to read the whole file into a byte array. But while doing so the values which are greater than 128 are read as negative values as we have Signedbyte in java(-127 to 128).
    So I tried reading the bytes into the int array as shown in the below code.
    int i = 0;
         int content[]= new int[(int)size];
         FileInputStream fstream = new FileInputStream(fileName);
         DataInputStream in = new DataInputStream(fstream);
         while(i<size)
         content= in.readUnsignedByte();
         i++;
    The above function 'readUnsignedByte();' reads byte and stores it into an int array.....But since the file contains around 34000 bytes ....the loop runs 340000 times .....which is a performance hazard.
    After googling for hours ....I could still not find any alternative ....
    I want to read byte and want to store in int array but instead of loop, I want to read the file at once.
    Or is there any way to implement Unsigned Byte in java so that I can read the entire file in byte array without corrupting the values which are greater than 128..
    I have to deliver the code asap .....Please help me out with an alternative solution for this...
    Thanks in advance....

    Thanks for replying ......
    Actually, I need to take the bytes into an array(int or byte array) with decimal values and further process these decimal values.......
    but while reading the file into a byte array the decimal values get corrupted(in case when I read a number greater than 128) but in this case I am able to read the whole file at once(without using any loop) as done by the following code
         FileInputStream fstream = new FileInputStream(fileName);
         DataInputStream in = new DataInputStream(fstream);
         byte b[] = null;
         in.readFully(b);
    and while reading the file in int array as done in the below code is inefficient as the number of times the loop runs is more than 34000..... please suggest me some alternative.
    int i = 0;
         int content[]= new int[(int)size];
         FileInputStream fstream = new FileInputStream(fileName);     
         DataInputStream in = new DataInputStream(fstream);
         while(i<size)
                   content= in.readUnsignedByte();
                   i++;

  • Unable 2 read bytes array of images

    I have made a client application which will
    receive an image from server
    the mobile app (clent) is reveiving bytes array in emulator
    but unable 2 receive it in real application...
    message = new byte[2073]; //string 2 read pic;
    for(i=0;i<2073;i++)
    //read pic array byte by byte
    x=is.read(); //(is is an input stream)
    message= (byte)x;
    // also tried this
    //is.read(message)
    works fine in emulator but not in real appication in sony erricson k310i

    sorry actually code was.....
    for reading byte by byte...............
    message = new byte[2073]; //string 2 read pic;
    for(a=0;a<2073;a++)
    //read pic array byte by byte
    x=is.read(); //(is is an input stream)
    message[a]= (byte)x; //problem in last post i[] //converting it into italic
    //for reading whole array message
    // also tried this
    is.read(message)
    and i think there shall be no problem in converting an[b] int into byte

  • Reading bytes from CLOB not BLOB

    I know that DBMS_LOB.SUBSTR can read number of bytes (for BLOBs) or characters (for CLOBs).
    What I want is to read bytes from BLOB instead of characters.
    The following tries to read 4000 bytes. Unfortunately It fails to read 4000 bytes if size of CLOB_COLUMN is bigger than 4000 bytes.
    select dbms_lob.substr(utl_raw.cast_to_raw(CLOB_COLUMN),4000,1) from dualIs it possible to get only these 4000 bytes from CLOB_COLUMN?
    Thank you in advance.

    Welcome to the forum.
    Unfortunately It fails to read 4000 bytes if size of CLOB_COLUMN is bigger than 4000 bytes.Could it be you're mixing up things?
    DBMS_LOB.SUBSTR reads bytes from BLOBS, characters from CLOBS.
    "amount Number of bytes (for BLOBs) or characters (for CLOBs) to be read."
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#sthref3199
    No need to cast_to_raw, afaik:
    SQL> create table t as select to_clob(lpad('*', 10000, '*')) clob_col from dual;
    Table created.
    SQL> desc t;
    Name                                                                   Null?    Type
    CLOB_COL                                                                        CLOB
    SQL> select substr(clob_col,1, 4000) substr
      2  ,      length(substr(clob_col,1, 4000)) substr_lngth
      3  ,      dbms_lob.substr(clob_col, 4000, 1) lob_substr
      4  ,      length(dbms_lob.substr(clob_col, 4000, 1)) lob_substr_length
      5  from t;
    SUBSTR                                                                           SUBSTR_LNGTH
    LOB_SUBSTR
    LOB_SUBSTR_LENGTH
    ********************************************************************************         4000
                 4000
    1 row selected.

  • How to read bytes(image) from a server ?how to display image after read byt

    How to read bytes(image) from a server ?how to display image after reading bytes?
    i have tried coding tis , but i couldnt get the image to be display:
    BufferedInputStream in1=new BufferedInputStream(kkSocket.getInputStream());
    int length1;
    byte [] data=new byte[1048576];
    if((length1=in1.read(data))!=-1){
    System.out.println("???");
    }System.out.println("length "+length1);
    Integer inter=new Integer(length1);
    byte d=inter.byteValue();

    didn't I tell you about using javax.imageio.ImageIO.read(InputStream) in another thread?

  • Reading bytea column over dblink

    Hi,
    I try to read bytea column from postgresql db over a dblink in Oracle DB. But I could not. How can I solve the problem?
    In windows environment there is a parameter in odbc driver bytea as LO. I could not find how to set it on unix odbc.
    Versions of products I Use:
    Postgresql 8.3.3 on redhat
    Oracle DB : 10.2.0.4 on HP/UX
    HSODBC : 10.2.0.4

    CURRENT_DATE is not supported:
    Supported SQL Syntax and Functions
    However, from reading this part:
    Supported SQL Syntax and Functions
    it becomes clear that you'll need to use a string of DATE datatype (in a fixed format) or select from a DATE column.
    You could just boldly try: to_date(CURRENT_DATE) , but you'll probably receive ORA-02070 again...

  • A better way to Read Bytes until Done ?

    My question involves reading an unknown number of bytes from the serial
    port. One method is to just wait a defined amount of time to receive
    the bytes and hope you caught all of them. Better: count them until
    they are all received. I have attached an image which shows the method
    I use to count bytes until all bytes are received. However, this method
    is rather slow. It's taking me 500mS to read data that I can normally
    read in 230mS. Is the shift register making this loop slow? Is there a
    better way to read the bytes until all bytes are in?
    Richard
    Attachments:
    ReadBytes.gif ‏5 KB

    Thanks for your reply Chilly.
    Actually, you are correct on both accounts, the delay and the wire from
    the output of Write, and in fact, I usually do those things. I was just
    in a hurry to get an example posted and didn't have my real data.
    To put my issue in broader prospective, I have attached an image that shows boh methods I've used to count bytes. One
    shows the method I use to count bytes until all bytes are received. The
    other is a "hard wired" timer method that I try to avoid, but at least
    it is fast. Notice the text in red. Why would I be able to read the
    byes so much faster in the "hard wired" version? It has to be either
    the shift register, the AND, or the compare functions, and I still
    can't beleive these things would be slower than the Express timer
    function in the other method.
    Methodology: The 235mS timer used in the "hard wired" method was
    emperically derived. The 150 bytes are received 100% of the time when
    235mS is allowed. 230mS yields about 90% of the bytes, the it goes down
    exponentially. I found that the shift register method method trakes
    ~515mS avg by putting a tick count on both sides of the loop and
    finding the resulting time. I also did that with the hard wired method
    and found it to be dead on 235mS which at least proves the Express vi
    works very well
    Message Edited by Broken Arrow on 09-05-2005 08:31 PM
    Message Edited by Broken Arrow on 09-05-2005 08:32 PM
    Richard
    Attachments:
    CoutingBytes.GIF ‏25 KB

  • Reading bytes from a server

    Ok,
    I want to connect to a server and recieve a data from it.
    the data is broken up as follows:
    int flag;
    int x, y;
    String name;
    the server i'm communicating with is written in C, so i'm trying to figure out how i'm going to recieve this data.
    What is the size that java uses to store an integer value?
    IF java uses unicode, that's two bytes per character right?
    so if name was 30 characters long it would be 60 bytes?
    i'm thinking of trying to either read the whole transmission into one string then separate, or separate as it comes in?
    could someone suggest how to proceed>

    Java holds (primitive) integers in 32 bits.
    Java holds characters in 16 bits (two bytes)
    30 characters will occupy 30*16 = 480 bits (60 bytes)
    Java provides the java.net package for networking. In there you can find a class called Socket that identifies the clients's communication endpoint, and encapsulates a host and an application address (port).
    First you open a socket to a server:
    Socket s = new Socket( serverName, serverPort );
    then you just read an input stream from the socket.
    DataInputStream dis = new DataInputStream( s.getInputStream() );
    String message = dis.readUTF(); //wait for server to send
    s.close() // close the socket
    Now, you can do with message whatever you like. It's that simple!
    For more information you can see the related tutorials from java.

Maybe you are looking for

  • Problem in creating A certificate for Depo excise for price escalation

    Hi all, There is a scenario where we transfer stocks OF 100 KG from manufacturing plant to depo..DID the  ME21N, VL10B, VF01, J1IIN, MIGO, J1IG. fROM DEPO DID va01 , VL01N, VF01, J1IJ FOR 50 qty. The later on while selling 10 KG from the depo the pri

  • Problem with uploading a file in Clustered Environment

    Hi, I have a problem with uploading a file in a clustered environment. I have an iview component which facilitates an upload action of an xml config file. The problem is that the upload of the modified XML file is reflected only in the central instan

  • Busy buffer wait

    Hi I am getting huge buffer busy waits events on my database and its increasing following is the result of query on my database(9.2.0.8.0) SQL> select event,total_waits from v$system_event where event in ('free buffer waits','buffer busy waits') 2 ;

  • RAID-1 for root/swap on Solaris 10 x86

    OK, now that I have solved my problem with the update manager I am in the process of trying to create RAID-1 volumes for root and swap. I am working my way through the process by following the procedure in Solaris Volume Manager Administration Guide.

  • T60 display problem - boot in low resolution pink/blue shade

    I have a T60 2623D7U that has a screen resolution of 1400x1050. The problem I am having is that when I start the laptop it starts up with a really low resolution, probably 640x480, and the colour of the screen sometimes has a pink or blue shade. Some