User Profile

Collapse

Profile Sidebar

Collapse
JonLT
JonLT
Last Activity: Apr 11 '09, 06:02 PM
Joined: Jul 24 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • JonLT
    replied to single byte access in memblock
    in C
    Thank you once again :)

    I'm planing on using TCP for starters. The application im developing is a IRC like chat server and client. But I'd like it to be able to send more than just strings.
    I'm using C++.
    If TCP proves to slow i'll try UDP with some custom checking on top.

    To get back to my initial question:
    The following is what i'm planning to do:

    The package:
    - size (2 bytes)...
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to single byte access in memblock
    in C
    Thank you very much for that answer. It made me think :)
    I didn't know anything about endianness, now i know a little bit. And i think a time-stamp in the header might be a good idear aswell.

    Again: Thank you very much!
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to single byte access in memblock
    in C
    yeah a struct might be a good idear, but im not sure that it takes the same amount of mem on all archs. So if i send some bytes from the server and cast them to a package struct in the client, im not sure ill get the right thing.

    What i really want is a type that uses the same amount of bytes on every arch. Do i need to make my own type, and if so - how would one do that?

    I know the above code doesnt work, its more like...
    See more | Go to post

    Leave a comment:


  • JonLT
    started a topic single byte access in memblock
    in C

    single byte access in memblock

    Hi!

    I'm trying to learn some network programming and right now im designing the package layout.
    I think ill do it like this:
    - first two bytes (an int): the size of the package
    - third byte: the type of the package
    - the rest: the data

    The problem is that i dont know how to access a singe byte in a memblock created by malloc.
    I guess i could use an unsiged char, but I'd like my app...
    See more | Go to post

  • JonLT
    replied to C++/Java integration
    in C
    pawn is open source (zLib/libpng) and lets you call c++ functions from a pawn-script and also call functions in the script from c++.

    The script is compiled using a pawn-compiler and is then executed in an abstract machine (from within the c++ source code).

    The compiler is also open source so it can be implemented in the host application along with the abstract machine.
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to C++/Java integration
    in C
    I've found a thing called pawn - and it does what i want. Sorry about the fast posting.
    See more | Go to post

    Leave a comment:


  • JonLT
    started a topic C++/Java integration
    in C

    C++/Java integration

    Hi!

    I could try to explain what I would like to do, but I think a little code would be much easier to understand. So here goes:

    C++ class:
    Code:
    class Cclass
    {
      void some_C_function(int i)
      {
        printf("%d\n",i);
      }
    };
    Java class:
    Code:
    Class Jclass extends Cclass
    {
      public void some_Java_function(int i)
    ...
    See more | Go to post

  • JonLT
    replied to virtual vs. function pointer
    in C
    Thank you very much. I am actually in the process of making a raytracer, and i'd like it to have a reasonable frame rate, so every little improvement is welcome, and from what you are saying it sounds like i need to avoid virtual function calls in the main loop.

    The reason i was using them in the first place, was to be able to do intersection tests with different objects by calling an intersectionTes t() function on some baseObject...
    See more | Go to post

    Leave a comment:


  • JonLT
    started a topic virtual vs. function pointer
    in C

    virtual vs. function pointer

    Hi

    I was just wandering what the difference between a overloaded virtual function and a function pointer member variable is?
    Im looking for the best execution time.
    Heres an example:
    [code=cpp]
    class someClass : public someOtherClass
    {
    public:
    virtual void f(); // this function is overloading f() in someOtherClass
    }
    [/code]
    [code=cpp]
    class isThisBetter...
    See more | Go to post

  • JonLT
    replied to SDL threads and gcc optimization
    in C
    Thanks for your reply!

    I just thought it would be easier to use the sdl threads. SDL is also crossplatform, which is importent, because we are developing as a group, and we use different OS's.

    A small correction to the initial post. When the program locks up, it only uses one core.
    This is the output from the gdb debugger:
    Code:
    [Thread debugging using libthread_db enabled]
    [New Thread -1215969088
    ...
    See more | Go to post

    Leave a comment:


  • JonLT
    started a topic SDL threads and gcc optimization
    in C

    SDL threads and gcc optimization

    Hi!

    My program (a raytracer) needs a lot of calculations so i thought it would be a good idear to use threads. I'm allready using the SDL lib in the program so the SDL threads seemed a good choice.
    The program runs fine and a faster with treads, but it's still to slow. I tried speeding it up with the gcc optimization flags, but that just makes the program lock up. The optimization falgs works fine if i don't use threads....
    See more | Go to post

  • Are you feeding the program the right command line arguments?
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to Pls Tell me How to achive this
    in C
    you properly DO need a "newline" at the end of your cout line.
    It could be a "\n" or a <<endl;

    The reason is the the newline flushes the stdout buffer. The text isn't printed right away, but stored in the stdout buffer, so if the program terminates before the buffer is flushed the output isn't printet
    [code=cpp]
    cout<<"Hello World!"<<endl;
    [/code]
    or...
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to Resetting a class
    in C
    how about this (I don't know how you code looks)
    Code:
    SomeClass MyClass;
    MyClass.someIntMember = 5;
    if(wantToReset)
    do the resetting
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to Weird Function Calling
    in C
    It's a function pointer
    Code:
    (int (*)(int))
    means a pointer to a function that returns an int and takes an int as an argument.

    EDIT: isn't it?
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to how to compiline c++ program from unix
    in C
    you want to compile unix code on a windows machine?
    You'll need GCC (use MinGW)
    It might also be easier if you have the library-files you need compiled in wondows (even thought that shouldn't be necessary if you use GCC)
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to opening a image file
    in C
    depends on the image file format. One of the easiest to do this with is .bmp i think. Take a look at a bmp file in you text-editor and you'll get a good idear of how to do what you say
    See more | Go to post

    Leave a comment:


  • JonLT
    started a topic using C as a OO langauge
    in C

    using C as a OO langauge

    Hi
    I've been using C++ quite a lot now, but i have recently moved over to C, and because of my experience with C++ i tend to use C in the same way as I used C++.

    e.g:
    [code=c]
    typedef struct SMyStruct
    {
    int A,B,C;
    } MyStruct;

    int myStruct_set_va lues(MyStruct* s, int a, int b, int c)
    {
    s->A = a;
    s->B = b;
    s->C = c;
    }
    ...
    See more | Go to post

  • JonLT
    replied to Resetting a class
    in C
    if you declare anything inside an if block the variable will run out of scope i.e end to exist when you are nolonger inside the if block, you need to put the declaration outside the if block
    See more | Go to post

    Leave a comment:


  • JonLT
    replied to typedef struct foo{} foo
    in C
    is it maybe the same as a class prototype?
    [code=cpp]
    class foo;
    [/code]
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...