From:             arrakaij at digitalinsanity dot de
Operating system: Linux / Ubuntu 12.04
PHP version:      Irrelevant
Package:          Sockets related
Bug Type:         Feature/Change Request
Bug description:Get blocking state, domain, protocol of a socket

Description:
------------
I am writing a oop socket wrapper for sockets in php (5.3+) and am missing
some functions (names are examples):

bool socket_get_blocking($socket);
/* Return whether a socket is blocking or not. streams do have this
function, however, sockets do not. this information is available in
php_socket struct, but there is no way to get this information. would be
required for better error handling, allowing/disallowing things etc */

(following function could be written as one, returning an array)

int socket_get_domain($socket);
/* returning AF_INET, AF_INET6, AF_UNIX and so on, whichever i gave the
socket_create() command */
int socket_get_protocol($socket);
/* returning SOL_TCP, SOL_UDP and so on, whichever i gave the
socket_create() command */
int socket_get_type($socket);
/* returning SOCK_STREAM, SOCK_DGRAM and so on, whichever i gave the
socket_create() command */

On C-Side there is e.g. the struct sockaddr that contains the domain. So it
should be no problem to adapt those information into PHP.

There is a workaround getting those last three informations, however, it is
very hard to find and not safe, as #defines can change. see below

Test script:
---------------
//Workaround for getting domain, type and family of an socket

$socketProtocol = socket_get_option($socket, 1, 38); //SOL_TCP, ...
$socketType = socket_get_option($socket, SOL_SOCKET, SO_TYPE);
//SOCK_STREAM, ...
$socketDomain = socket_get_option($socket, 1, 39); //AF_INET,...

Expected result:
----------------
(easy) possibility to get information that are provided to sockets in php

Actual result:
--------------
for the informations mentioned, there are no functions available

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63979&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63979&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63979&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63979&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63979&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63979&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63979&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63979&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63979&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63979&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63979&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63979&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63979&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63979&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63979&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63979&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63979&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63979&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63979&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63979&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63979&r=mysqlcfg

Reply via email to