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)...
User Profile
Collapse
-
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!Leave a comment:
-
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...Leave a comment:
-
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... -
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.Leave a comment:
-
I've found a thing called pawn - and it does what i want. Sorry about the fast posting.Leave a comment:
-
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:
Java class:Code:class Cclass { void some_C_function(int i) { printf("%d\n",i); } };
...Code:Class Jclass extends Cclass { public void some_Java_function(int i) -
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...Leave a comment:
-
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... -
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
Leave a comment:
-
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.... -
Are you feeding the program the right command line arguments?Leave a comment:
-
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...Leave a comment:
-
how about this (I don't know how you code looks)
Code:SomeClass MyClass; MyClass.someIntMember = 5; if(wantToReset) do the resetting
Leave a comment:
-
It's a function pointer
means a pointer to a function that returns an int and takes an int as an argument.Code:(int (*)(int))
EDIT: isn't it?Leave a comment:
-
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)Leave a comment:
-
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 sayLeave a comment:
-
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;
}
... -
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 blockLeave a comment:
-
is it maybe the same as a class prototype?
[code=cpp]
class foo;
[/code]Leave a comment:
No activity results to display
Show More
Leave a comment: