Hi,
I just started using Commonc++ and I think to use it for part of my diploma
project. By playing around with the UDPBroadcast class I got some problems.
#include <cc++/socket.h>
int main(int argc, char **argv)
{
bool val = flase;
const char cadd[] = "10.10.20.111";
const char cnet[] = "10.10.255.255";
InetAddress hadd(cadd);
BroadcastAddress nadd(cnet);
UDPBroadcast *bcast;
bcast = new UDBroadcast(hadd, 1200); // here it crashes
bcast->setPeer(nadd, 1200);
val = bcast->isBroadcast();
char msg[] = "test";
bcast->Sent((void*)msg, 4);
delete bcast;
}
I compiled this piece of code with:
gcc -I/usr/local/include/ -g -xc++ udptest.cc -o udp -lccxx -lpthread.
without getting errors.
I have loaded udp into gdb and I placed a breakpoint on the line:
bcast = new UDPBroadcast(hadd,1200);
As gdb passed this line I got the message "Program received signal SIGABRT, aborted. 0x2ab07341 in __kill () from /lib/libc.so.6 .
After this I derived my own class form UDPSocket and I called from the
constructor an overwritten version of the method setBroadcast(true).
in the setBroadcast method i place the same code as in the original one.
After compiling I placed a breakboint directly in the setBroadcast method and I saw the the call setsockopt(so,SOL_SOCKET,SO_BROADCAST, (char*)&enabel, (socklen_t)sizeof(enable)));
failed.
I don't have any idea how to solve this problem. Does somebody has a tip?
My system: Calderae desktop 2.4, kernel 2.2.14, gcc v2.95.2
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I just started using Commonc++ and I think to use it for part of my diploma
project. By playing around with the UDPBroadcast class I got some problems.
#include <cc++/socket.h>
int main(int argc, char **argv)
{
bool val = flase;
const char cadd[] = "10.10.20.111";
const char cnet[] = "10.10.255.255";
InetAddress hadd(cadd);
BroadcastAddress nadd(cnet);
UDPBroadcast *bcast;
bcast = new UDBroadcast(hadd, 1200); // here it crashes
bcast->setPeer(nadd, 1200);
val = bcast->isBroadcast();
char msg[] = "test";
bcast->Sent((void*)msg, 4);
delete bcast;
}
I compiled this piece of code with:
gcc -I/usr/local/include/ -g -xc++ udptest.cc -o udp -lccxx -lpthread.
without getting errors.
I have loaded udp into gdb and I placed a breakpoint on the line:
bcast = new UDPBroadcast(hadd,1200);
As gdb passed this line I got the message "Program received signal SIGABRT, aborted. 0x2ab07341 in __kill () from /lib/libc.so.6 .
After this I derived my own class form UDPSocket and I called from the
constructor an overwritten version of the method setBroadcast(true).
in the setBroadcast method i place the same code as in the original one.
After compiling I placed a breakboint directly in the setBroadcast method and I saw the the call setsockopt(so,SOL_SOCKET,SO_BROADCAST, (char*)&enabel, (socklen_t)sizeof(enable)));
failed.
I don't have any idea how to solve this problem. Does somebody has a tip?
My system: Calderae desktop 2.4, kernel 2.2.14, gcc v2.95.2