|
-
Apr 1st, 2004, 11:31 PM
#1
Thread Starter
Hyperactive Member
Asyncronous Socket Server Question
I was just wondering if a Asyncronous Socket server could be considered a Multi-Threaded server? By design, an Asyncronous socket server makes calls on new threads, yet not using the Threading Namespace. The Asyncronous server seems to act identical to a multithreaded socket server as far as needing to SyncLock, etc, ie, sharing the same problems as a mthreaded server. I'm just wondering if there are any real differences between the two? As far as I can tell, the only real difference is with a multithreaded server, it's a bit easier to keep track of each client but thats nothing a simple collection type data structure can't solve in a asyncronous enviroment. Can anyone give me any real feedback on the reasoning on why one would choose to design one over the other?
-
Apr 2nd, 2004, 03:25 PM
#2
Fanatic Member
i've been writing an asynchronous socket server wrapper class now for awhile.. haven't had time to work on it as of late, but i would defenitley advise you to use asynchronous sockets instead of multithreading...
the major reason is that the threads are handled and created in the system's threadpool... this is more efficient than doing it yourself with the Threading namespace, as well, easier to code for you!
you're right though, you do run into some of the same problems with both, like having to lock certain objects that may be accessed at the same time...
also, let me save you some time by reminding you that if you have events and call/fire them from within an asynchronous call, they WILL be fired on a seperate thread... you will run into problems with this if you try to handle those events on a windows form or something, since you can't technically access objects on the form from a thread that is not the main form's thread...
but, to wrap all that up, i WILL be beginning to release my socket server and socket client classes in a couple weeks, as soon as i'm done school and have a bit more time to document them, and make them stable enough to be considered near final... they will be free, and possibly open source.. not sure yet...
stay tuned...
-
Apr 3rd, 2004, 04:03 AM
#3
Thread Starter
Hyperactive Member
Originally posted by Redth
also, let me save you some time by reminding you that if you have events and call/fire them from within an asynchronous call, they WILL be fired on a seperate thread... you will run into problems with this if you try to handle those events on a windows form or something, since you can't technically access objects on the form from a thread that is not the main form's thread...
Yes I too have noticed this, and it's a shame that I have not been able to find any help dealing with this problem. I have a Asynchronous server and client, the server does fine since it's in a module and self contianed but the client has many different windows that are opened up by the instruction of the server. I run event's to the clients main form but when the user needs to open up a inventory list or somthing like that, the server will send the inventory along with a tag telling the client to open up the new window/form that is used to display the inventory. at that point the thread gets tied up in the new form and doesn't return to it's calling routine until the user closes the inventory form. This is a major problem I have yet to figure out. I have tried a few different methods, I tried opening up the form in it's own thread, that doesn't work... Have you figured out a way around this little problem by chance?
-
Apr 4th, 2004, 03:22 PM
#4
yay gay
About the form thing you can use the Form's BeginInvoke/Invoke to execute code on the form's thread then avoiding all the problems said above
\m/  \m/
-
Apr 5th, 2004, 06:44 AM
#5
Thread Starter
Hyperactive Member
Originally posted by PT Exorcist
About the form thing you can use the Form's BeginInvoke/Invoke to execute code on the form's thread then avoiding all the problems said above
Aye, I have read that a few places but as of yet, unsuccessful to get it working correctly, and unable to locate any good examples that would fit my problems scenario, have you any examples to share?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|