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.
socket_listen
(PHP 4 >= 4.1.0, PHP 5)
socket_listen — Bir soketi bağlantı kabul etmek için dinler
Açıklama
$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:
kuyrukdeğiştirgesine atanacak değer çalışılan platforma büyük oranda bağımlıdır. Linux üzerinde kendiliğindenSOMAXCONN'a düşürülür. Win32 üzerindeSOMAXCONNatanı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
- socket_accept() - Soket üzerinden bağlantı kabul eder
- socket_bind() - Soketi bir isimle ilişkilendirir
- socket_connect() - Soket üzerinde bir bağlantıyı ilklendirir
- socket_create() - Bir soket oluşturur (iletişim için bir uç)
- socket_strerror() - Bir soket hatasıyla ilgili açıklamayı döndürür
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).
