|
Home > Archive > Unix Programming > January 2005 > possible way to write a server
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
possible way to write a server
|
|
| nonone 2005-01-06, 5:56 pm |
| Hi
First of all i'd like to sorry for my english and asking propably such
popular question, but i can't find the solution in the internet . I'm
writeing a simple comunication server something like small ICQ or
Instant Messenger. and I finde 3 ways to do it and I don't know which
one is the best:
1. A Blocking sockets and Select/Poll
2. A fork/thread with shared memory
3. A NonBlocking sockets and signals
This server between managing clients request should also do some job
for example 'ping' the connected hosts so I think the 3rd option will
be the best, but I can't find amy examples in net and spent many
nights and nothing done .
If you know which one of this solutions is the best and know where can
I find examples (it will be nice for C language ) I would be very
grateful.
thanks for all help
Nonone
nonone@pf.pl
| |
| David Schwartz 2005-01-06, 5:56 pm |
|
"nonone" <nonone@pf.pl> wrote in message
news:13df7e6d.0501060835.6a1b7408@posting.google.com...
> Hi
> First of all i'd like to sorry for my english and asking propably such
> popular question, but i can't find the solution in the internet . I'm
> writeing a simple comunication server something like small ICQ or
> Instant Messenger. and I finde 3 ways to do it and I don't know which
> one is the best:
> 1. A Blocking sockets and Select/Poll
> 2. A fork/thread with shared memory
> 3. A NonBlocking sockets and signals
Most likely non-blocking sockets with select or poll. It is almost
always a bug to use select/poll with blocking sockets.
DS
| |
| Heiner Steven 2005-01-28, 5:54 pm |
| David Schwartz wrote:
> "nonone" <nonone@pf.pl> wrote in message
> news:13df7e6d.0501060835.6a1b7408@posting.google.com...
[...]
The right design depends on what your server does, and on
the number (and activity) of your clients.
[Legend: '+': advantage, '-': disadvantage, 'o': point to mention]
[vbcol=seagreen]
+ often easy to implement
+ no (thread) synchronization issues
- may be too slow for many requests
- operating system bugs may cause the server to "hang" (e.g.
poll() returns with "data available" -> read(fd, ...) ->
process blocks in read()
[vbcol=seagreen]
+ better suited for more load (particularly when using
"worker-threads")
- thread/process concurrency and synchronization problems
- many (thousands) of infrequently used connections may cause
big resource usage
[vbcol=seagreen]
- signals are not a good thing to rely on
4. (Solaris) /dev/poll
+ faster and more efficient than poll()/select()
- not portable
5. (Solaris 10) event ports
+ faster and more scalable than /dev/poll
- not portable
[vbcol=seagreen]
> Most likely non-blocking sockets with select or poll. It is almost
> always a bug to use select/poll with blocking sockets.
Heiner
--
___ _
/ __| |_ _____ _____ _ _ Heiner STEVEN <heiner.steven@nexgo.de>
\__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_| http://www.shelldorado.com/
|
|
|
|
|