[ Home ] Passports | National Anthems in MP3 | Live chat

Live chat

News | Forum
 

Train Museum:

Warsaw, PolandSeoul, KoreaKyoto, Japan Forums: Rail UK, Rail Australia
Pictures: MoneyMonorailHong Kong light festival High speed trainQueen Elizabeth II in YokohamaTaro - Galapagos Tortoise



Subject: Re: Efficient methods Posted on: Injection- Sat, 20 Feb 2010 15:03:55 +0000 (UTC)

karthikbalaguru
wibbled on Saturday 20 February 2010 13:10


> While reading about the various designs, interestingly i
> came across an info that the design of TCP servers is
> mostly such that whenever it accepts a connection,
> a new process is invoked to handle it .

Not generally true these days - used to be the method of choice, see
below...

> But, it seems that in the case of UDP servers design,
> there is only a single process that handles all client
> requests. Why such a difference in design of TCP and
> UDP servers ? How is TCP server able to handle
> large number of very rapid near-simultaneous connections ?
> Any ideas ?
>

First I recommend signing up to O'Reilly's Safari books onlinbe service - or
buy some actual books. There are some excellent O'Reilly books specifically
on TCP/IP.

In the meantime, speaking generally (without embedded systems specifically
in mind):

TCP = reliable stream connection oriented protocol. No worrying about
sequences, out of order packet delivery, missed packets - except in as much
as your application needs to handle the TCP stack declaring it's given up
(exception handling). Some overhead in setting up (3 way handshake) and
closedown.

UDP = datagram protocol and your application needs to worry about all the
rest above, if it cares. But very light - no setup/closedown.

Regarding TCP service architechture, there are 3 main classes:

1) Forking server;
2) Threaded server;
3) Multiplexing server;

1 - simplest to program, heaviest on system resources. But you can
potentially (on a real *nix system) simply write a program that talks to
STDIN/STDOUT and shove it behind (x)inetd and have a network server without
a single line of network code in your program. Perfectly good method for
light load servers where latency is not an issue.

2 - Popular - little harder to program, much more efficient, assuming your
OS can handle thread creation more lightly than process creation.

3 - Very efficient. One process maintains a state for all connections, often
using event methodology to call service subroutines when something
interesting happens (eg new connection, data arrived, output capable of
accepting data, connection closed). Sounds horrible, but with an OO
approach, very easy to get your head around. Now bearing in mind that
anything in OO can be bastardised to a handle and an array of struct which
holds the equivalent data that an OO object would, this could be a very
suitable method for emebedded systems where C may be the language of choice
and there may be no OS or only a very simple one that doesn't map well.

Now, doing 3 wouldn't be so far different to doing it all in UDP *except*
you now have to care about packet delivery unreliability - as you can get a
variety of stacks for many embedded systems, why not let someone else's hard
work help you out?

--
Tim Watts

Managers, politicians and environmentalists: Nature's carbon buffer.

491476. Re: dd command for remote disk copy? 491476
491477. Re: problems with wvdial 491477
491478. Re: problems with wvdial 491478
491479. Re: dd command for remote disk copy? 491479
491480. Re: dd command for remote disk copy? 491480
491481. Re: dd command for remote disk copy? 491481
491482. Re: Downloading only a particular page/selective pages of a document
491483. Re: problems with wvdial 491483
491484. Re: dd command for remote disk copy? 491484
491485. Re: dd command for remote disk copy? 491485
491486. NetworkManger config. & usage? 491486
491487. NetworkManger config. & usage? 491487
491488. Re: Linux friendly Laptops and Netbooks?? 491488
491489. Re: NetworkManger config. & usage? 491489
491490. ar5b95 wifi adapter 491490
491491. Global Warming fake science and what you can do to against it 491491
491492. [OT] Re: Global Warming fake science and what you can do to against i
491493. ssh, openswan, openvpn or ...? 491493
491494. Re: ssh, openswan, openvpn or ...? 491494
491495. Re: ssh, openswan, openvpn or ...? 491495