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

search for in the

socket_listen> <socket_import_stream
[edit] Last updated: Fri, 23 Mar 2012

view this page in

socket_last_error

(PHP 4 >= 4.1.0, PHP 5)

socket_last_errorSoket üzerindeki son hatanın kodunu döndürür

Açıklama

int socket_last_error ([ resource $soket ] )

İşlev soket değiştirgesi belirtilerek kullanılırsa belirtilen soket üzerinde son oluşan hatanın kodu döndürülür. Bir soket belirtilmezse başarısız olan son işlemle ilgili hata numarası döner. İkincisi, bir hata durumunda bir soket döndürmeyen socket_create() ve belli bir soketle doğrudan ilişkili olmayan bir sebeple başarısız olabilen socket_select() gibi işlevler için yararlıdır. Elde edilen hata kodunu socket_strerror() işlevinde kullanarak hatanın açıklamasına içeren bir dizge almak mümkündür.

Değiştirgeler

soket

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

Dönen Değerler

Bir soket hata kodu döner.

Örnekler

Örnek 1 - socket_last_error() örneği

<?php
$socket 
= @socket_create(AF_INETSOCK_STREAMSOL_TCP);

if (
$socket === false) {
    
$errorcode socket_last_error();
    
$errormsg socket_strerror($errorcode);

    die(
"Soket oluşturulamadı: [$errorcode$errormsg");
}
?>

Notlar

Bilginize:

socket_last_error() hata kodunu temizlemez, bunun için socket_clear_error() işlevini kullanın.



add a note add a note User Contributed Notes socket_last_error
ca at php dot spamtrak dot org 15-Dec-2009 07:33
This is a bit long, but personally I prefer to use the standard C defines in my code.

<?php

define
('ENOTSOCK',      88);    /* Socket operation on non-socket */
define('EDESTADDRREQ'89);    /* Destination address required */
define('EMSGSIZE',      90);    /* Message too long */
define('EPROTOTYPE',    91);    /* Protocol wrong type for socket */
define('ENOPROTOOPT',   92);    /* Protocol not available */
define('EPROTONOSUPPORT', 93);  /* Protocol not supported */
define('ESOCKTNOSUPPORT', 94);  /* Socket type not supported */
define('EOPNOTSUPP',    95);    /* Operation not supported on transport endpoint */
define('EPFNOSUPPORT'96);    /* Protocol family not supported */
define('EAFNOSUPPORT'97);    /* Address family not supported by protocol */
define('EADDRINUSE',    98);    /* Address already in use */
define('EADDRNOTAVAIL', 99);    /* Cannot assign requested address */
define('ENETDOWN',      100);   /* Network is down */
define('ENETUNREACH',   101);   /* Network is unreachable */
define('ENETRESET',     102);   /* Network dropped connection because of reset */
define('ECONNABORTED'103);   /* Software caused connection abort */
define('ECONNRESET',    104);   /* Connection reset by peer */
define('ENOBUFS',       105);   /* No buffer space available */
define('EISCONN',       106);   /* Transport endpoint is already connected */
define('ENOTCONN',      107);   /* Transport endpoint is not connected */
define('ESHUTDOWN',     108);   /* Cannot send after transport endpoint shutdown */
define('ETOOMANYREFS'109);   /* Too many references: cannot splice */
define('ETIMEDOUT',     110);   /* Connection timed out */
define('ECONNREFUSED'111);   /* Connection refused */
define('EHOSTDOWN',     112);   /* Host is down */
define('EHOSTUNREACH'113);   /* No route to host */
define('EALREADY',      114);   /* Operation already in progress */
define('EINPROGRESS',   115);   /* Operation now in progress */
define('EREMOTEIO',     121);   /* Remote I/O error */
define('ECANCELED',     125);   /* Operation Canceled */
?>

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