CakeFest 2024: The Official CakePHP Conference

socket_getsockname

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

socket_getsocknameBelirtilen soketin yerel tarafını sorgulayıp soket türüne göre ya bir konak/port çifti ya da bir Unix dosya yolu döndürür

Açıklama

socket_getsockname(Socket $soket, string &$adres, int &$port = null): bool

Bilginize: socket_getsockname() işlevi socket_connect() ile oluşturulan AF_UNIX soketlerle kullanılmamalıdır. Sadece socket_accept() ile oluşturulan soketler ve socket_bind() çağrısından sonra bir birincil sunucu soketi için anlamlı bir değer döner.

Bağımsız Değişkenler

soket

socket_create() veya socket_accept() ile oluşturulmuş geçerli bir Socket örneği.

adres

Belirtilen soket AF_INET veya AF_INET6 türündeyse socket_getsockname() işlevi, bu bağımsız değişkende bir IP adresi (127.0.0.1 veya fe80::1 gibi) ve port bağımsız değişkeninde de belirtilmişse ilgili port numarasını döndürür.

Belirtilen soket AF_UNIX türündeyse bu bağımsız değişkende (/var/run/daemon.sock gibi) bir Unix dosya yolu döner.

port

Belirtilmişse ilgili port değeri bu bağımsız değişkene konur.

Dönen Değerler

Başarı durumunda true, başarısızlık durumunda false döner. Soket AF_INET, AF_INET6 veya AF_UNIX türünde değilse işlev false döndürebilir, ancak böyle bir durumda son soket hata kodu güncellenmez.

Sürüm Bilgisi

Sürüm: Açıklama
8.0.0soket artık bir Socket örneği olabiliyor; evvelce resource türündeydi.

Ayrıca Bakınız

  • socket_getpeername() - Belirtilen soketin yerel tarafını sorgulayıp soket türüne göre ya bir konak/port çifti ya da bir Unix dosya yolu döndürür
  • socket_last_error() - Soket üzerindeki son hatanın kodunu döndürür
  • socket_strerror() - Bir soket hatasıyla ilgili açıklamayı döndürür

add a note

User Contributed Notes 1 note

up
1
CXJ
9 years ago
Curiously, getsockname() works for socket_create() and socket_create_pair() Unix-domain (AF_UNIX) sockets if one calls socket_bind() after creation to name the formerly anonymous socket(s).

Using a socket_bind() call also results in a file system "file" (socket, first character 's' in an "ls -l" listing) being created with the given name. Such a "file" will need to be removed explicitly, as closing the socket will not remove it.
To Top