a question about socket and arrays !

wutongjoe_at_hotmail.com
Date: 04/22/04


Date: Thu, 22 Apr 2004 22:47:48 +1200

hi, I just began with studying java and have a question about reading
bytes from file(fileA).Every time I make it read into a byte array with
size 256.I used a while loop to see whether the next byte is a -1,if it
is then stop .

             int c,j=0;
             mByteData=new byte[256];
             while ((c=mByteSource.read())!= -1&&j<256){
                 mByteData[j]=(byte)c;
                j++;
             }

Q1: what is the second array like if the file size is 270kb ?(first 14
are bytes from file and rest are null ? or empty ? or zero ?)

Q2 : if I copy the array byte after byte using a for loop like

             
             byte[] b2=new byte[256];
             for(int i=0;i<256;i++){
                         b2[i]=b1[i];
             
             }

             how can I write bytes to fileB and make fileA and fileB identical?
(MD5 sum)
             because every time I found from 14th byte all the rest bytes
        are all zeros ,there is no -1 and I do not know where to stop if I
        want to write them to fileB.

---------------------------------------------------------------------------
Question about socket:

I am going to send packets to the server using lots of threads(one
packet per thread) and what should the server do? does it listen with
same amount of socket threads and then use them to send back the
acknowledgments? or just one socket listening on all coming packets ?
(after received,I will write them to a file,so it is like a uploading app)

Am I clear enough ?



Relevant Pages

  • Re: n/w transfer coding question
    ... >> If I understand correctly, instead of sendto; to send a datagram, I ... > TIME_WAIT or FIN_WAIT after you've closed them so the socket number won't be ... > time and send 'packets' through it? ... >> also I presume on the rx side I'll need to set a socket listening? ...
    (comp.sys.acorn.networking)
  • Re: n/w transfer coding question
    ... > possibly not the most efficient way but should this methodology work? ... TIME_WAIT or FIN_WAIT after you've closed them so the socket number won't be ... time and send 'packets' through it? ... > also I presume on the rx side I'll need to set a socket listening? ...
    (comp.sys.acorn.networking)
  • Re: Problem with writing fast UDP server
    ... UDP packets per second. ... socket and threads. ... I wrote a simple case test: client and server. ... The maximum theoretical limit is 14,880 frames per ...
    (comp.lang.python)
  • RE: *warning* student question
    ... What option is this supposed CRC or hash supposed to be? ... >their shell session you're taking over their network socket. ... Systems will also drop TCP packets with bad checksums. ... We provide Ethical Hacking, Advanced Ethical Hacking, Intrusion ...
    (Security-Basics)
  • Re: [patch 4/10] s390: network driver.
    ... but it seems someone is complaining about some behavior changing? ... network driver discard packets on link-down. ... However this approach doesnt play well if the socket can ... be blocked completely because of /one/ interface having its link ...
    (Linux-Kernel)