I have a java app that creates a socket to talk to a server process, eg new java.net.Socket(String host, int port). This app includes a bunch of legacy c++ code that needs to suck gobs of data from that server and process it. This is currently implemented by having the native code create its own socket and connect to the server, eg:
soc...
I am fairly new to developing C/C++ code in MSVS but one of the things that has already confused me is why, after adding a set of source and header files to my project such that they show up respectively under the MSVS folders 'Source Files' and 'Header Files', do I subsequently have to tell the compiler where my header files are under '...
I would like to define a simple template function which takes a runtime value and determines if it is a member of some set of possible values.
Usage:
int x; // <- pretend this came from elsewhere...
if (isoneof(x, {5,3,9,25}) ...
Something like:
template <typename T, size_t size>
bool isoneof(T value, T (&arr)[size])
{
for (siz...
There is a multiplayer card game which I had first programmed as a non-forking socket server in C (using poll() call).
Then it was too difficult for me to add new features and I've switched to Perl (using IO::Poll module).
As Perl doesn't support readv()/writev(), requires more memory/CPU and also isn't very commercial (I'd like to sel...
Let v1 be the target vector, v2 needs to be appended to the back of it.
I'm now doing:
v1.reserve(v1.size() + v2.size());
copy(v2.begin(), v2.end(), back_inserter(v1));
Is this the most efficient way? Or can it maybe be done just via copying a chunk of memory?
Thanks!
...
Hi,
I can sort a int* array using stl,
plain and simple like
std::sort(myarray, myarray + size);
Is there any equal simple way to randomize it?
thanks
...
Hi,
I am using RCF for Inter Process Communication in a project. Is there a way in RCF to create a bi directional channel. I will have server and client running in both processes. I was able to get one way commmunication working with Win32NamedPipes Here is the server
int main()
{
MyServiceImpl myServiceImpl;
RCF::RcfServer serv...
Extends
In Tools/Options/Environment/Fonts and Colors, If you choose to "Show settings for" Text Editor and look in the Display items dialog it says there' a "Read-Only" region you can set the font for.
I'm not sure what's that for? Where do you encounter the read-only regions this dialog wants to set the font for?
...
I have a socket that listens on some port.
I send the SIGSTOP signal to the thread that waits on the port(using accept) and terminate it. then I close the fd of the socket that I waited on. But for the next run of my project it doe's not allow me to listen on that port again.
My program is in C++ under linux.
What should I do?
Some part...
I find this situation comes up from time to time, and I never seem to have a really robust generic solution to it.
I have a control - in this example an EDIT control on a dialog. I want to take certain actions in response to the user - and only the user - modifying the contents of the edit control.
The edit control can be set programm...
Hi,
I started to use rappidXML a short time ago and I just noticed that when I reassign a node Pointer mallocDebug (I am using xCode on a mac) complains. This is what I do:
xml_node<>* rootNode = doc.first_node("Root");
//find shaders
xml_node<>* curNode = rootNode->first_node("Node1");
.... do something
curN...
I am trying to integrate some external code into my application. My code was pure C, but the new code is C++, so I simply renamed my C files to .cc and compiled the whole thing with g++.
It compiles fine, but I get a crapton of link errors :
CMakeFiles/svrt.dir/svrtH_generator.cc.o: In function `operator new(unsigned long, void*)':
svr...
I need to do logging in a c++ application. After googling for a while, I decided to use log4cpp.
is that a safe option to go with, or is there something better out there?
How do get started with installation and importing it to my application using windows xp, Visual Studio 2005?
TIA
...
I'm in an intro to C++ class and I was wondering of a better method of checking if input was the desired type.
Is this a good way of doing this? I come from a PHP/PERL background which makes me rather apprehensive of using while loops.
char type;
while (true) {
cout << "Were you admitted? [y/n]" << endl;
cin >> type;
if (...
Hi
I noticed in Effective STL that
vector is the type of sequence that
should be used by default.
What's does it mean? It seems that ignore the efficiency vector can do anything. Could anybody offer me a scenario that vector is not a feasible option but list must be used?
Thanks!
...
I know this is partially subjective, but hopefully with enough specifics I can get a good answer.
I am looking to develop an accounting app targeted at a specific market segment (think Quickbooks, but tweaked). Most of the app will be editable tables that are linked with DB data and some basic reporting and graphic functionality.
It mu...
Scenario: I would like a window control which is a sub-window in my dialog (a subwindow of a subwindow) to propagate its notification messages out to the dialog window.
e.g. A COMBOBOX contains an EDIT control. I have a circumstance where I would really like to know when the EDIT field gains and loses focus (mainly because the stupid CO...
Let's say I have a class with union members in it:
class ClassX {
public:
union {
StructA * A;
StructB * B;
};
}
If I have pointers x1 and x2 to different ClassX objects, does this:
x1->A = x2->A;
Have the same effect as this:
x1->B = x2->B;
? Thanks.
...
I just stumbled upon a change that seems to have counterintuitive performance ramifications. Can anyone provide a possible explanation for this behavior?
Original code:
for (int i = 0; i < ct; ++i) {
// do some stuff...
int iFreq = getFreq(i);
double dFreq = iFreq;
if (iFreq != 0) {
// do some stuff with iFre...
I'm writing a simplified calculator using Qt with C++, for learning purposes. Each number is a QPushButton that uses the same slot to modify the text in a lineEdit widget being used as a display.
The slot uses the sender() method to figure out which button was pressed, so the correct number would be written on the display widget.
In or...