Internet Server

Mark Papadakis markp at pathfinder.gr
Fri Dec 4 20:19:03 EET 1998


Hm,

Fysika h select().
Giati na kolisei o server?
prostehse to descriptor tou socket pu exeis kanei bind() sto descriptors list su kai otan iparxei kati pu prepei na to ksereis, i select tha sto dwsei.. An eisai se loop kai fovasai min koliseis, dwse ena timeout value sti select.. des parakatw..

Allh lysh einai na xrisimopoiieiseis threads kai pipes i fork kai pipes antistoixa alla h kalyterh ( kata th gnwmh mou ) lysh einai h select(). 

Des to paradeigma.


fd_set myfds;
..
FD_ZERO(&myfds);
FD_SET(&myfds, socket1);
blah blah
kai vale to socket pu ekanes bind()
FD_SET(&myfds, bindedsocket);

while(1)
{

	struct timeval tv;
 tv.tv_sec =0;
 tv.tv_usec=5000; // make sure we are not blocking anything..

  a = select(maxsocks+1, &myfds, blah blah .. , &tv) // Edw an theleis vale kai timeout value gia na min 'blockarei' h process.. 

  if(a && FD_ISSET(&myfds, bindedsocket))
  {
        // rock'n'roll time..blah blah do whatever u need to do
	newcoket = accept(bindedsocket, 0, 0);
	close(bindedsccket);
	// blah blah..
  }


}

Mark

Michael wrote:
>HI se olous ...
>=20
>Thelw na ftiaxw ena daemon gia TCP port . Kserw pws na xrhsimopoihsw
>tis =
>socket functions alla exw to exhs problem :
>=20
>Otan kalw thn accept() , o server tha kollhsei mexri na yparxei kapia
>=
>incoming connection . Yparxei kapios tropos ( ektos apo thn select()
>, =
>giati etsi to programma tha prepei na diavazei synexws to socket ) ,
>na =
>kaleitai aytomata mia synarthsh tou programmatos otan to socket exei
>=
>etoimh incoming connection ?
>
>ThankX
>

--
====================================================================
Gia boithia (h na diagrafhte) e-mail sto majordomo at argos.hol.gr
Ta archives tis listas einai sto http://www.argos.hol.gr/lists :
prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users
====================================================================



More information about the Linux-greek-users mailing list