Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   General Gnutella Development Discussion (https://www.gnutellaforums.com/general-gnutella-development-discussion/)
-   -   Network Model (https://www.gnutellaforums.com/general-gnutella-development-discussion/9417-network-model.html)

Gemini March 20th, 2002 06:24 AM

Network Model
 
Hum, after reading the second part on How to Program a gnutella client , I must admit I did not really understand how I could implement an asynchronous server. :rolleyes:
How in a more detailed manner does it work. In fact, I don't understand how we can hadle multi connection without a multithread. I guess it is because my knowledge is still too poor.

Could anyway light my bulb on that issue and explain to me how i could implement it.

Unregistered March 20th, 2002 07:55 AM

It's called select(). It's a standard system call or library function or whatever it is on all OSs.
It monitors a bunch of file descriptors and returns when one of them becomes readable and/or writable and/or an exception occured.

maksik March 22nd, 2002 07:35 AM

Check Mutella's source code (http://mutella.sourcefprge.net). Asyncroneous socket support is provided by MAsyncSocket class (asyncsocket.h, asyncsocket.cpp)

if you have some particular questions I may try to help

--Max

Gemini April 1st, 2002 01:17 PM

Thanks
 
Thank you guys I think now i can make it work.
Cheers for helping me.

loStHead May 27th, 2002 07:53 AM

Hi!

I understand how asynchronous sockets work. But what about funcions that cause a delay or block the program, like connect() ?
I used this kind of sockets on my Gnutella and Im having trouble with connect(), which blocks until it gets a response or a time out (that could be more than 2 minutes).

Should I create a new thread to handle this kind of functions or is there a way not to use threads at all?

cultiv8r May 27th, 2002 08:28 AM

loStHead,

I'm using synchronous sockets actually, which is one thread per connection. I simply create a new thread and pass the socket handle (of an incoming connection), or ask the thread to connect. All non blocking.

Asynchronous is event driven, and a bit harder to keep in sync, IMO. But that depends on programming experience.

loStHead May 27th, 2002 08:55 AM

Right.
Ive been thinking about mixing asynchronous sockets and syncronous, or whatever, using poll() to watch for events on a main thread, while other thread handles incoming connections (blocks in an infinite listen), and many more threads handling outgoing connections. That is, when they connect (full handshaking) the thread exits and joins the main thread.

What I actually want is not to use threads at all, if possible, as Mutella (I guess) does.

Thats the only solution I could think about but Im sure anyone here can help me through this.


All times are GMT -7. The time now is 04:54 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.