User Profile

Collapse

Profile Sidebar

Collapse
tomPee
tomPee
Last Activity: Mar 31 '09, 11:29 PM
Joined: Jun 3 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Ah yeah, offcourse. My bad.
    Thanks :)...
    See more | Go to post

    Leave a comment:


  • Code:
      final char[] ch = new char[fileNameLength];
                 for (int i = 0; i < fileNameLength; i++) {
                     final int tmp = in.read();
                     if (tmp == -1) {
                         throw new IOException("End of stream prematurely ended.");
                     } else {
                         ch[i] = (char) tmp;
                     }
                }
    ...
    See more | Go to post
    Last edited by JosAH; Feb 15 '09, 12:00 PM. Reason: fixed the [code] ... [/code] tags

    Leave a comment:


  • Hehe,

    Yeah, we figured we'd just go for the simplest policy of not supporting non-ASCII file names :P. It's not really a prerequisite either so we can easily skim on some on the difficulties there :).

    Kind Regards,
    Tom
    See more | Go to post

    Leave a comment:


  • Hi,

    Hm, that indeed does look nice :). Though, the only difference with what we're doing now is the type field, which is specified by our protocol to be send in a specific order, it looks quite the same as what we are doing :).

    Only, for sending out integers we use a dataoutputstrea m sending 4 byte integers, big endian. But the rest is quite the same.

    I don't think we'll be changing it anymore though as it...
    See more | Go to post

    Leave a comment:


  • Hi,

    As a matter of fact, we do use XML for message passing. I don't know what ASN.1 is though.
    It's just, we can't send files in XML messages...
    We were in the need of sending mixed datatypes, lengths, characters and binary data over one one socket.
    Where, lengths also includes the length of the xml message being send.
    See more | Go to post

    Leave a comment:


  • Hi,

    I just wanted to let you know that I've found it :). The 'final' version (except for the debug output) is much like the above. I've used DataInputStream s and DataOutputStrea ms to be able to easily send and receive integers.
    To receive characters, I just read the bytes one by one until all have been read ( as advertised by the length ) and cast them to characters which works nicely.
    For the binary data I also read...
    See more | Go to post
    Last edited by Nepomuk; Feb 11 '09, 12:15 AM. Reason: Fixed [code] tags

    Leave a comment:


  • Hey,

    As it seems the people working on the C++ counterpart are not sending the lengths of the filenames and the lengths of the files are being send as integers (4 bytes long).
    Now, keeping in mind that characters are encoded in UTF-8 by default i've thought up of the following 'draft' implementation:

    Both the fReader and fWriter are actually DataInput/OutputStreams.

    Code:
    /*
    	 * (non-Javadoc)
    ...
    See more | Go to post
    Last edited by JosAH; Feb 10 '09, 11:13 AM. Reason: fixed the [code] ... [/code] tags

    Leave a comment:


  • Oh, the standard encoded size of a char is 1 byte ? I thought it was 2 bytes... If it's 1 byte that indeed simplifies the matter a bit. And I didn't know the String class itself took care of the encoding.
    Thanks a lot Jos, I'll try and get it fixed that way. I'll post here if another corpse jumps out of the closet on my line of thought.

    Thanks a lot already !

    Greets,
    Tom
    See more | Go to post

    Leave a comment:


  • But, I can't send the java file object since we have to 'interface' with c++. Or isn't that what you meant ?
    The thing is also, we want it to be possible to for example 10 files after one another without having to openup new connections.

    So far what I'm thinking that might work is just sending bytes over and casting everything to chars, but I think it'll be a bit inefficient. But I think it might work...

    So, just using...
    See more | Go to post

    Leave a comment:


  • Hi,

    Thanks for the reply :).

    What I'm not sure about with the reusing of a stream is both the closing of the stream, and the buffered data.
    If data enters on the original stream, is it copied to, for example both the buffer for the BufferedInputSt ream and to the buffer of a BufferedReader, or is it only present in one of the buffers ?
    The latter case would be quite problematic as I would never know where my data...
    See more | Go to post

    Leave a comment:


  • Sending both binary data and strings over the same stream

    Hi,

    I've bumbed into a slight problem now, and I just don't seem to know how to fix it. What I want to do is the following:
    Send over a socket:
    1. Number of files to be send (not as an integer, just as a string)
    then for each file to be send:
    2. Length of Filename (again as a string)
    3. Filename
    4. File as binary data.

    I grabbed my Core Java book and figured it'd be easily...
    See more | Go to post

  • Hi,

    thanks for the reply :).
    I don't have an inheritance design yet, as i was only developing the base class.
    The classes that do inherit the base class would only need to have the open() function reïmplemented.
    As open() would then see what menu to print and what to do with the output handed to it. (It's for a console application).

    And you're probably right, i do need a singleton. It makes sense,...
    See more | Go to post

    Leave a comment:


  • tomPee
    started a topic Non static function needs acces to static datamembers
    in C

    Non static function needs acces to static datamembers

    Hi,

    I have the following problem:
    I am trying to make some sort of base class menu that i can then use to derive other menu's from. Those menu's should then be able to interact with each other.
    And, i have most of the idea figured out and I thought out how i want to do it. But when i started coding i found a slight... difficulty.
    It might be easy to overcome, but google let me down :( and my own imagination...
    See more | Go to post

  • tomPee
    replied to strange class declaration
    in C
    Hi,

    SharedImage() is the constructor of the class, and it can intialize values ( even so before starting the body of the constructor, which is between the {}.

    This code simply states that the constructor of sharedImage initializes the datamember 'refCount' at 0.

    Initializating is needed when you:
    - Have a const data member in your class
    - Have a reference datamember in your class.
    ...
    See more | Go to post

    Leave a comment:


  • Make utility in Unix. Make over different directories

    Hi,

    I have no idea if this is the right section to post this in. But i thought it maybe belonged here most.

    The problem i having is actually, most likely really simple. But here i am running for help. I have read a lot about make files, but well, not a single one actually sais something about the approach i'm using.

    Which ofcourse might perfectly mean i'm doing something completely wrong. :P.
    ...
    See more | Go to post

  • tomPee
    replied to Floating-Point
    in C
    Dang that's some nice solutions ! :)
    It really pays of reading a lot of threads, you learn so much out of them.
    It really surprises me that C++ can do all that. Quite the nice language :) Though you have to think about those special tricks when the problems that could require them arise, that's allways equally hard sadly enough, though that's my own experience ;)

    Cheers adrian !
    -Tom...
    See more | Go to post

    Leave a comment:


  • tomPee
    replied to Count frequency of prepositions from input text
    in C
    [hijack_post]
    Hmm, what's the map ? Is it built in in C++ ? :)
    Because, i have programming experience in Oberon, but i'm quite new to C++ so i'm not all that familiar with all it's possibilities yet.
    Could you explain how to use a map please ? :D
    Thanks in advance :)
    [/hijack_post]

    -Tom

    PS: Hijack is spelled like that right ?...
    See more | Go to post

    Leave a comment:


  • tomPee
    replied to Count frequency of prepositions from input text
    in C
    Thanks ! :D

    And yes, the list of prepositions indeed can't become larger, but when you start using the file to recognize other paterns than only prepositions it could become bigger, but i shouldn't have used the word prepositions there :D....
    See more | Go to post

    Leave a comment:


  • tomPee
    replied to Count frequency of prepositions from input text
    in C
    Well, what i would do is, but it might be a bit to much of topic, i don't know that for sure, so you be the judge ^^.
    Thinking about reusability and a nice design i'd try something like this.

    You can read in two files: one file of prepositions and another one containing the text you have to search.
    Read all the prepositions and put them in a list of records ( or structs, or classes with the instructions to increment...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...