downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

socket_read> <socket_last_error
[edit] Last updated: Fri, 23 Mar 2012

view this page in

socket_listen

(PHP 4 >= 4.1.0, PHP 5)

socket_listenBir soketi bağlantı kabul etmek için dinler

Açıklama

bool socket_listen ( resource $soket [, int $kuyruk = 0 ] )

socket_create() ile bir soket oluşturulup socket_bind() işlevini kullanarak bir isimle ilişkilendirilince soket bir dinlenen soket haline gelir.

socket_listen() sadece SOCK_STREAM ve SOCK_SEQPACKET türündeki soketlere uygulanabilir.

Değiştirgeler

soket

socket_create() ile oluşturulmuş geçerli bir soket özkaynağı.

kuyruk

İşlem için kuyruğa alınacak azami gelen bağlantı sayısı. Dolmuş bir kuyruğa gelen bir bağlantı ya ECONNREFUSED belirten bir hata alır ya da ilgili protokol yeniden bağlanmayı destekliyorsa yineleme başarılı olacağından istek yok sayılır.

Bilginize:

kuyruk değiştirgesine atanacak değer çalışılan platforma büyük oranda bağımlıdır. Linux üzerinde kendiliğinden SOMAXCONN'a düşürülür. Win32 üzerinde SOMAXCONN atanırsa makul bir azami değer kullanımından ilgili hizmet sağlayıcı sorumludur. Windows üzerinde bu değer için standart bir yaklaşım yoktur.

Dönen Değerler

Başarı durumunda TRUE, başarısızlık durumunda FALSE döner. Hata kodu socket_last_error() işlevi ile alınabilir. Bu hata kodunu socket_strerror() işlevine aktararak hatayı açıklayan dizgeyi alabilirsiniz.

Ayrıca Bakınız



add a note add a note User Contributed Notes socket_listen
Karuna Govind (karuna.kgx gmail) 15-Jul-2008 10:10
To change the maximum allowed backlog by your system (*nix machines only), first you need to find the variable for this limit:

sudo sysctl -a | grep somaxconn

On ubuntu boxes, it returns net.core.somaxconn (you need to look for the 'somaxconn' variable, the full name will vary across different systems).

Update this to a large number as follows:

sudo sysctl -w net.core.somaxconn=1024

This will work straight away. no restart required.
lewislp at yahoo dot com 30-Aug-2005 06:13
socket_listen() cannot be used for UDP communications as discussed below.

In addition, the example below discusses UDP connections, which only exist if the application manages them through a state table (the OS does not create a UDP connection upon receiving a datagram).  Having a function named socket_connect() that determines the remote IP and port only confuses the matter by giving the indication of some sort of connection handshake between two hosts.  Rather, socket_connect() only specifies the remote IP and port used by subsequent socket_send() calls.  You can achieve the same effect by skipping socket_connect() altogether and specifying the remote IP and port in socket_sendto() calls.

If you find yourself writing a connection-based protocol on top of UDP, consider using TCP.  If your application requires streaming data of some sort, use TCP to manage connections and control messages, and UDP to handle the streaming data (H.323 is an example of a suite of TCP and UDP protocols working in conjunction).

 
show source | credits | stats | sitemap | contact | advertising | mirror sites