Rate my scanner object.

This is a discussion on Rate my scanner object. within the C++ Programming forums, part of the General Programming Boards category; Just thought this may be useful to someone. This is a generic scanner that can be used to tokenize any ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652

    Question Rate my scanner object.

    Just thought this may be useful to someone.

    This is a generic scanner that can be used to tokenize any (I think!) programming language. The interface is straightforward, easy to use, and also compatible with other STL code.

    Please let me know what you think!
    Attached Files Attached Files
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  2. #2
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Um... Where is the implementation source? If it is in the library, I don't think we could rate anything but the interface.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    The point is that it is a useful object. So test it, and rate it on that merit. You can't see the implementaion for vsprintf(), can you? But how do you rate it? Get my point?
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  4. #4
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Just a question. And yes, it is indeed useful but I can't say more because I don't use the STL so iterators and stuffs are almost unknown to me. (I know the theory but not the use, neither interface nor implementation)

    But I have one question, your parser does not allow us to check the syntax, does it? For instance, a variable must begin with a letter or an underscore but not a number...

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    Good point. The next release will allow you to optionally define tokens using BNF notation, meaning you will be able to do that using a rather concise syntax. This would also remove the 'ordinal precedance' requirement that is described in the documention.

    If you have never used the STL, I strongly encourage that you learn how to use it. Generic programming is the future, as they say.
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  6. #6
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    It might be useful to see the implementation. That way we can offer suggestions and people can learn from what you did. I am very interested in programming language design and knowing how you parsed the code might be some use to me (not to copy, hell no, but to see how it works). Perhaps you do it more efficiently than my code?

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    At some point, yes, I will release the source code. An interesting note is that the scanner was coded in less than 100 lines!
    As far as speed goes, a hard-coded scanner would obviously run more efficiently, of course, but the downside is the lengthy development time involved and it's lack of flexibility. If nothing else, the generic one can be used to jump-start a project until a hard-coded implementation is developed.
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  8. #8
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    If you have never used the STL, I strongly encourage that you learn how to use it. Generic programming is the future, as they say.
    Thanks, but I already learn about the generic way to do things, I mean templates. If I don't use the STL it is because I prefer more low-level manipulations. I don't know how to use it but if I had to make use of it one day, I could learn quite quickly as I know about almost every concepts there. I studied the library even if I don't use it.

    Um... And may I ask, are you planning on doing a compiler or an interpreter thing?

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    Yes, I hope to develop a compiler. In fact, if you or anyone else is interested, please let me know. I think it would be an excellent project, for both personal reasons and for the fact that it would build recognition for all involved. Anyway, I know what you mean about the STL. For a long time I had been using generic programming techniques (even wrote a subset of a 'template' library for the C programming language), but put off using the STL. But the main thing is that it is portable, and other programmers can easily assimilate your code into theirs. That commonality is a very compelling reason for using the STL almost exclusively.
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  10. #10
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Thanks for the offer but I'm not used to work in team and I don't think it could bring your project any good. (because I have never worked before actually and working together is somethign you learn quite late at school here)
    Besides, I don't have much knowledge in algorithm. (though I studied quite basic things, data structures & array and list sort)
    Anyway, if you want, I could give you some help.

    However, I must warn you that the optimizing part of your compiler will be quite painful. Because I spent quite a while learning assembly for speed purpose, but eventually, I ended up with an unexpected answer to all my questions: my compiler does the work as well as I do or even better than me.

    Not that I am saying that you cannot do better work than the compiler but it is hard.

    About the STL, well, I don't work for portability and besides, other programmers can easily understand what I'm writting because I use but C to do the work, arrays and pointers. I know quite well pointers and for one who has done much more C than C++, I tend to stick with my pointers. ^^ I know it could be dangerous sometime but not necessarily as much people say. I think the main problem is that people nowadays learn C++ without knowing well what was once called "C" and is now only a part of the world-known language C++. Actually, the only answer you can get from a teacher is "use the standard containers" for what before you would have got "take your pointers and try to understand".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting object after list removal (C++ visual studio)
    By RancidWannaRiot in forum Windows Programming
    Replies: 2
    Last Post: 10-20-2005, 06:06 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  3. Dynamic Object Creation (and Management)...
    By Comrade_Yeti in forum C++ Programming
    Replies: 3
    Last Post: 07-31-2005, 01:44 PM
  4. Set Classes
    By Nicknameguy in forum C++ Programming
    Replies: 13
    Last Post: 10-31-2002, 01:56 PM
  5. Testing object pointer for null
    By VanJay011379 in forum C++ Programming
    Replies: 4
    Last Post: 07-24-2002, 10:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21