Are there any plans to implement either a reliable message sending option to the udp sockets, or a tcp socket? Some basic examples to demonstrate usage might help beginners out too (I might code an example up if I have some time).
There are two Socket classes for TCP (ListenerSocket/CommSocket) :) But yes, they're next to impossible to understand because I never find the time to write proper examples. Any contributions would be very welcome...Tuiq? ;) (Sorry that I can't go into detail, exam time again...)
By ?
Date 2009-01-22 21:58
Awesome. I missed that one while browsing the documentation. These seem pretty straight forward, though :-)
By ?
Date 2009-01-24 03:53
So I've played around with the sockets for a bit, and this might just be my misunderstanding of boost.... on the socket events (onReceive, onDisconnect) for a CommSocket, how do I know which CommSocket fired that event? Thanks
By ?
Date 2009-01-24 13:43
Ok so it was my misunderstanding of boost that was the problem.
The following worked fine: void someDisconnectFunction() { /* ... */ } int main() { ... commSocket.onDisconnect = someDisconnectFunction;
But when I tried to actually assign the function pointer to a specific object's method such as: struct Foo { void barThatDisconnected() { /* ... */ } }; int main() { ... Foo foo; commSocket.onDisconnect = foo.barThatDisconnected; // or any variant of that I could think of
it would not work. I dug around in boost for a (long) while and figured out that what you need to do to be able to attach the function pointers to actual objects methods is as follows: struct Foo { void barThatDisconnected() { /* ... */ } }; int main() { ... Foo foo; commSocket.onDisconnect = boost::bind(&Foo::barThatDisconnects, foo); // if onDisconnect took 3 paramaters you would pass bind 3 more paramaters (literally the text _1, _2, and _3 such as boost::bind(&Foo::barThatDisconnects, foo, _1, _2, _3);
I hope this saves someone the headache I went through.