I have all traffic from port 50 redirected to 5050 using
iptables -t nat -A POSTROUTING -p udp --dport 50 -j REDIRECT --to-port 5050
I listen using a RAW Socket on 5050, and I see IP packets from 0.0.0.0:50 to 0.0.0.0:5050.
The original destination address is obviously not present, since this seems to be a separate redirection packet...
I'm writing a simple program for testing mouse. It compiles fine, but doesn't work. When I launch it, the window freezes. What am I doing wrong?
#include <SDL/SDL.h>
#undef main
int main()
{
if (SDL_Init (SDL_INIT_EVERYTHING) != 0)
return 1;
SDL_Surface* Scr;
if ((Scr = SDL_SetVideoMode (300, 200, 32, 0)) == 0)
...
I think I can sum up the use of generics in Java in one word: type-safety.
Can you conclude the use of templates in C++ in one word, please?
...
I'm a total noob when it comes to linking and building with Visual Studio. I would like to integrate Lua into my C++ console application.
Can someone give a step by step on how to do this from getting the Lua dependencies from lua.org, to actually running a "Hello World from Lua" in VS, and all the steps in between.
Finding something ...
Inside a C++ template function foo(), a call to ::bar(TT*) gives the following error under gcc 4.4.3:
g++ -o hello.o -c -g hello.cpp
hello.cpp: In function 'void foo(std::vector<TT*, std::allocator<TT*> >&)':
hello.cpp:8: error: '::bar' has not been declared
Here's the offending code:
// hello.cpp
#include <vector>
template<typenam...
I'm trying to write a very simple implementation of Document Object Model library in order to provide a generic data structure to use in my further projects.
Just to keep things simple I defined only three main classes: node, element and attribute. A node is defined by it's name (e.g. all html tags) and basically is a container for an el...
#include <stdio.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main (void) {
char buff[256];
int error;
lua_State *L = lua_open(); /* opens Lua */
luaL_openlibs(L);
while (fgets(buff, sizeof(buff), stdin) != NULL) {
error = luaL_loadbuffer(L, buff, strlen...
typedef unsigned char uChar;
typedef signed char sChar;
typedef unsigned short uShort;
typedef signed short sShort;
typedef unsigned int uInt;
typedef signed int sInt;
typedef unsigned long uLong;
typedef signed long sLong;
I have a list of typedefs so when I define variables, I can be exact. For instance, if I only need the numbers...
I'm trying to create a recurring struct method in my code to walk through a binary search tree. But I'm getting errors on compile and unsure what is the cause.
I've got Node* findNode(const Node *, const Object &); in the private section of the .h file
and
Node* BSTree::findNode(const Node* current, const Object &target){
if(*current...
There are some member variables and mutexes associated with the object, so it would be easier to use a member function rather than a standalone function.
...
clock_t a = 0;
clock_t b = 100;
while(a<b)
{
// get current time
a = clock();
}
It seems that it is an infinite loop. Can the while loop be broken out of?
...
Hello,
why or for what reason is it not possible to declare a class member variable in C++ as "static mutable"? Something like
static mutable int t; //This won't compile
For me, there is no reason to ban such declarations. E.g. for reasons like maintaining a global class-wide statistics, it may be convenient to have static variable t...
I'm having an issue. I have a class with an overloaded operator like this..
class Foo
{
friend bool operator<(const Foo &a, const Foo &b);
...
};
bool operator<(const Foo &a, const Foo &b)
{
return a.member < b.member;
}
Then in a function in a class that holds some Foos in a map as keys...
void Bar::Update()...
I have the need to implement factory class in C++, but when I was thinking about that, I found one big problem that I couldn't solve, and I found out, that all factory implementation examples around are flawed in the same way. I'm probably the one who is wrong, but please tell me why.
So here is simple "typical" factory implementation, ...
iarray<T>& operator = (iarray<T>& v)
Why the return type is iarray<T>& not iarray<T> ?
UPDATE
Can someone elaborate in great detail why iarray<T> const &v ?
...
I've downloaded google test, but now I've no idea on how to link it to my project in eclipse.
Should I add it as a source folder? Should include it as g++ included library? And how can I run test then?
...
I have read there are a few flags in gcc to do catch some of the type violations for calls to printf, I haven't been able to find if there are similar ways to achieve this in Visual C++'s compiler (any version of VC++, from 2005 onward).
...
Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?
memory is vector of 1000 elements
array[] is an integer array of 1000 elements
for (iteration = 0; iteration < numiterations; iteration++) {
for (j = 1; j < numints; j++) {
memory...
I have the following piece of code:
if (book.type == A) do_something();
else if (book.type == B) do_something_else();
....
else do so_some_default_thing.
This code will need to be modified whenever there is a new book type
or when a book type is removed. I know that I can use enums and use a switch
statement. Is there a design patte...
Hi All,
I'm having a problem with stl map. Initially I fill the map with data like so.
//loop
pair< int, int > xy (x,y);
currentMap.insert( make_pair(xy), value); //map< pair<int, int>, bool>
prevMap.insert( make_pair(xy), value);
// End Loop
Then I delete an element according to some rules like so.
currentMap.erase( make_pair(xy) )...