I having estrange problems with a C++ class that abstracts me of Unix domain sockets.
After calling accept function all starts behaving rarely and I don’t know why.
The following function accepts new requests but after it returns, a simple call to any function gets locked!
UnixSocketClient *Accept(int d)
{
sockaddr_un *clientUnixAddr;
int clientUnAddrSize = sizeof(sockaddr_un);
int clientSD;
clientSD = accept(d,
(sockaddr *) clientUnixAddr,
(socklen_t *) &clientUnAddrSize);
int *bkp = new int;
memcpy(bkp, &clientSD, sizeof(int));
// it doesn't work passing clientSD only! I have to memcpy() always, why!!!!!????
return new UnixSocketClient(*bkp, clientUnixAddr);
}
For instance.
UnixSocketClient *c = Accept(socketDesc);
// but when I invoke Send() method it gets executed normally until it reach the return point. There gets blocked.
c->Send("hello");
I Also tried doing a simple:
cout << "after" << endl;
with the same result.
I know the accept function returns correctly because I started the debugger but the immediately next function (or method) stops at return point.