Forum > Networking and Web Programming

Networking for a newbie

<< < (2/2)

Ok, above pasted code is now much out of date but i've gotten rid of all problems, and it works for UDP aswell  :D So i might write few tips for using synapse that is basically multithreaded:

1) The most clean way to kill a connection is send a small exitcode (say a string "#Exit#) for counterpart. This will quickly end your thread without waiting for an error, which in UDP case will never come.

2) If you provide threads with pointer to a main controller class, be sure to handle cases when it is destroyed. Each thread = open socket, if you keep socket objects in main class (like i do) make sure that threads don't have pointers to null objects. What i did was copied over the pointers to socket objects and if thread was alive on main class.Destroy, just nil them in main class, Terminate thread and tell them to free sockets.
Basically avoid bruteforcing the threads, just give them Terminate code and if socket is listening or on long timeout; AbortSocket.


[0] Message Index

[*] Previous page

Go to full version