I am looking into developing a small (read:rudimentary) web server on a linux platform and I have no idea where to start.
What I want it to be able to do is:
Listen on a specific port
Take HTTP post and get requests
Respond appropriately
No session management required
Has to be in C or C++
Has to run as a service on boot
I am famili...
How do I protect /etc/passwd and /etc/shadow from concurrent access? I don't see any locking mechanism in pwd.h. I see the manual for pwd_mkdb mentions obtaining a lock, but is it just locking the file for exclusive access?
Is there a convention for locking these files if I were to write a utility to modify them directly, or through t...
I have data in the following format:
4:How do you do?
10:Happy birthday
1:Purple monkey dishwasher
200:The Ancestral Territorial Imperatives of the Trumpeter Swan
The number can be anywhere from 1 to 999, and the string is at most 255 characters long. I'm new to C++ and it seems a few sources recommend extracting formatted data with ...
The full error I'm getting is this:
error: ambiguous overload for ‘operator[]’ in ‘a[boost::_bi::storage4<A1, A2, A3,
boost::arg<I> >::a4_ [with A1 = boost::_bi::value<MsgProxy*>, A2 = boost::arg<1>, A3 =
boost::arg<2>, int I = 3]]’
It references line 116 of a class I have, which is the boost::bind call in this function:
// Dis...
According to my memory the following piece of code should compile fine on C++ but not in C.
Only problem is how to test it? It compiled fine with g++ and also with gcc. I'm assuming that g++ is C++ compiler and gcc is C compiler. I've tried it with mingw under Windows. Am I correct? if not then how to compile it using C compiler.
int ma...
I noticed while making a program that a lot of my int type variables never went above ten. I figure that because an int is 2 bytes at the shortest (1 if you count char), so I should be able to store 4 unsigned ints with a max value of 15 in a short int, and I know I can access each one individually using >> and <<:
short unsigned int S...
// I prefer to perform forward declaration on myclass, as I do not
// wish to ship "myclass.h" to client
// However, the following code doesn't allow me to do so, as class defination
// is needed in header file.
//
// a.h
#include "myclass.h"
class a {
public:
a();
myclass me;
};
I try to do it another way around. However, I ...
I try to forward declare concurrent_bounded_queue ;
class MyClass {
namespace tbb {
template<typename T> class cache_aligned_allocator;
template<class T, class A = cache_aligned_allocator> class concurrent_bounded_queue;
};
// I wish to maintain this syntax.
tbb::concurrent_bounded_queue<std::string>& co...
Why can't I compile the program 1 when the the program 2 is working fine ? Why is it's behavior different?
Program 1:
#include <iostream>
typedef int s1;
typedef int s2;
void print(s1 a){ std::cout << "s1\n"; }
void print(s2 a){ std::cout << "s2\n"; }
int main() {
s1 a;
s2 b;
print(a);
print(b);
...
Over the years I've developed a small mass of C++ server/client applications for Windows using WinSock (Routers, Web/Mail/FTP Servers, etc... etc...).
I’m starting to think more and more of creating an IPv6 version of these applications (While maintaining the original IPv4 version as well, of course).
Questions:
What pitfalls might I...
I'm trying to launch a Java app from a C++ app using the following code:
#include <windows.h>
#include <memory.h>
#include <tchar.h>
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
STARTUPINFOW siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupI...
Can someone describe what advantages a C or C++ programmer would have over a .Net programming when developing for Windows?
...
Given P1 and P2, how can I get the angle from P1 to P2? Thanks
...
hi I am trying to visualize a music file in gstreamer using the following command:
gst-launch filesrc location=file.mp3 ! decodebin ! audioconvert !
tee name=myT myT. ! queue ! autoaudiosink myT. ! queue ! goom !
colorspace ! autovideosink
But I get this error : "There may be a timestamping problem, or this computer is too slow."
P...
Hello,
I am a fairly new software developer currently working adding unit tests to an existing C++ project that started years ago. Due to a non-technical reason, I'm not allowed to modify any existing code. The base class of all my modules has a bunch of methods for Setting/Getting data and communicating with other modules.
Since I ju...
I'm writing a lambda calculus interpreter for fun and practice. I got iostreams to properly tokenize identifiers by adding a ctype facet which defines punctuation as whitespace:
struct token_ctype : ctype<char> {
mask t[ table_size ];
token_ctype()
: ctype<char>( t ) {
for ( size_t tx = 0; tx < table_size; ++ tx ) {
t[tx] = isal...
.dylib is the dynamic library extension on OSX, but it's never been clear to me when I can't / shouldn't use a traditional unix .so shared object.
Some of the questions I have:
At a conceptual level, what are the main differences between .so and .dylib?
When can/should I use one over the other?
Compilation tricks & tips (For example,...
Is there an easier way to do it than this, and if this is the only way, are there any potential memory leaks here?
CImage img1;
int dimx = 100, dimy = 100;
img1.Load(filename);
//filename = path on local system to the bitmap
CDC *screenDC = GetDC();
CDC *pMDC = new CDC;
pMDC->CreateCompatibleDC(scree...
The following code works fine for Visual C++ 2008. However, when comes to Visual C++ 6, I get the following error. May I know why, and how I can fix the error, but still make the destructor remains in private.
class X
{
public:
static X& instance()
{
static X database;
return database;
}
private:
X() {}...
I'm using ESE (JetBlue) in an app, when JetAttachDatabase is called it returns JET_errDatabaseDirtyShutdown. What am I supposed to do in my app? my desire is for any uncommeted transactions to be deleted
...