Considering c++ doesnt implement automatic garbage collection I understand that its a good idea to keep tight control of memory usage. I know that you can initialise a variable using the new and then...
Type: Posts; User: megatron09
Considering c++ doesnt implement automatic garbage collection I understand that its a good idea to keep tight control of memory usage. I know that you can initialise a variable using the new and then...
I think I could solve this using a for loop. However I would need to know how to empty and resize a character array. Here is a quick sketch of what I was thinking of doing...
//Sends a string of...
I wouldnt normally have the += but i've been messing around with the code and forgot to switch it back properly. ;)
Its not that I cant pass strings to send()
The problem is that i'm trying to pass a specific 8-byte 'header' packet. This has to be done correctly so that the server can pick it up and split it...
According to this its..
int send(int sockfd, const void *msg, int len, int flags);
However if I pass anything other than char the compiler will give me..
94 C:\xmlgbx\gbx\socketwrap.cpp cannot...
I cannot use std::string at all for some reason. When I do it somehow corrupts the 8-bytes and all communication with the server breaks down.
One other thing, the code I posted above it slightly...
I have written a program that communicates with a server via sockets. To make my life easier I created a 'socket' class which takes care of all the low-level socket stuff. One of the methods is...
I know i'll probably get sneered at for suggesting this, but try learning something easier first. I started to learn programming from scratch only a few months back, and my first choice was python. ...
I appreciate your advice Mario, but I just wanted to know incase there was a situation where I had to explicitly unlock a mutex. I doubt there is, and i'm sure another method could be devised where...
Thanks Mario, that helps a lot :)
The reason I was so puzzled was due to me not understanding all the jargon just yet ;)
When 'destructors' and 'scope' were mentioned as being the conditions in...
Thanks, that clears things up a lot. I can see why std::cout would need to be locked, as i'm guessing that allowing two threads to write to the output stream at one time would produce a mangled mess...
I am building a multi-threaded c++ app using the boost::thread library. I am just a bit confused about when I should be using locks and mutex's. I understand that it is essential that global objects...
Thanks for the info, just a few questions..
How do you mean the union is overkill? Does it need more memory or resources to work? I will probably use your suggestion regardless since you pointed...
Thats ok, as long as it contains the correct binary value to send through a stream socket. It doesnt need any string methods. Thanks for clarifying that.
Will this work both ways, i.e if i assign values to 'size' and 'handle' will 'bytes' contain the correct value?
Yeah its a tricky concept to grasp after coding scripted languages for all this time. I'm starting to get the hang of it now however ;)
Just found out what that means. Good idea thanks - sorry i'm a newbie to this ;)
Okay, i've tried writing a function template to take arguments of varying numbers and types. It didnt go so well. Here is what it looks like..
std::string XmlGbx::parseString(std::string pstr){...
This is a nice solution. However I will probably stick to the template function. The engine doesnt need to be entirely generic as I know exactly what kind of calls I can expect. It is not designed to...
Ah, that helps a lot. Thanks! :)
EDIT: How do I check if the parameter has been left out. Say if I use the int method, what if an int value is passed to that param. If it is an un-used param i'm...
Because there are many possible combinations of types used and the order they will be in (the order is important). So i'm not sure what your code does but if it does the same thing then I may use it....
I've just read up on overloaded template functions and I think i'll do it this way. The only problem is I need a way to tell what type i'm handling when the the argument is processed, so it can be...
This may help.
I'll have a look at boost::any although I was hoping it was possible within the standard library.
The reason I need this is that i'm building an xmlrpc client to communicate with a server. I want...
I learnt to program in python and php, so i'm used to having dynamic and associative lists (php's array, and pythons dictionary). As c++ requires you define the type of each variable, and define the...