Back to index

php5  5.3.10
php_sockets.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Chris Vandomelen <chrisv@b0rked.dhs.org>                    |
00016    |          Sterling Hughes  <sterling@php.net>                         |
00017    |                                                                      |
00018    | WinSock: Daniel Beulshausen <daniel@php4win.de>                      |
00019    +----------------------------------------------------------------------+
00020  */
00021 
00022 #ifndef PHP_SOCKETS_H
00023 #define PHP_SOCKETS_H
00024 
00025 /* $Id: php_sockets.h 321634 2012-01-01 13:15:04Z felipe $ */
00026 
00027 #if HAVE_SOCKETS
00028 
00029 extern zend_module_entry sockets_module_entry;
00030 #define phpext_sockets_ptr &sockets_module_entry
00031 
00032 #ifdef PHP_WIN32
00033 #include <winsock.h>
00034 #else
00035 #if HAVE_SYS_SOCKET_H
00036 #include <sys/socket.h>
00037 #endif
00038 #endif
00039 
00040 PHP_MINIT_FUNCTION(sockets);
00041 PHP_MINFO_FUNCTION(sockets);
00042 PHP_RSHUTDOWN_FUNCTION(sockets);
00043 
00044 PHP_FUNCTION(socket_select);
00045 PHP_FUNCTION(socket_create_listen);
00046 #ifdef HAVE_SOCKETPAIR
00047 PHP_FUNCTION(socket_create_pair);
00048 #endif
00049 PHP_FUNCTION(socket_accept);
00050 PHP_FUNCTION(socket_set_nonblock);
00051 PHP_FUNCTION(socket_set_block);
00052 PHP_FUNCTION(socket_listen);
00053 PHP_FUNCTION(socket_close);
00054 PHP_FUNCTION(socket_write);
00055 PHP_FUNCTION(socket_read);
00056 PHP_FUNCTION(socket_getsockname);
00057 PHP_FUNCTION(socket_getpeername);
00058 PHP_FUNCTION(socket_create);
00059 PHP_FUNCTION(socket_connect);
00060 PHP_FUNCTION(socket_strerror);
00061 PHP_FUNCTION(socket_bind);
00062 PHP_FUNCTION(socket_recv);
00063 PHP_FUNCTION(socket_send);
00064 PHP_FUNCTION(socket_recvfrom);
00065 PHP_FUNCTION(socket_sendto);
00066 PHP_FUNCTION(socket_get_option);
00067 PHP_FUNCTION(socket_set_option);
00068 #ifdef HAVE_SHUTDOWN
00069 PHP_FUNCTION(socket_shutdown);
00070 #endif
00071 PHP_FUNCTION(socket_last_error);
00072 PHP_FUNCTION(socket_clear_error);
00073 
00074 #ifndef PHP_WIN32
00075 typedef int PHP_SOCKET;
00076 # define PHP_SOCKETS_API PHPAPI
00077 #else
00078 # define PHP_SOCKETS_API __declspec(dllexport)
00079 typedef SOCKET PHP_SOCKET;
00080 #endif
00081 
00082 typedef struct {
00083        PHP_SOCKET bsd_socket;
00084        int           type;
00085        int           error;
00086        int           blocking;
00087 } php_socket;
00088 
00089 #ifdef PHP_WIN32
00090 struct sockaddr_un {
00091        short  sun_family;
00092        char   sun_path[108];
00093 };
00094 #endif
00095 
00096 PHP_SOCKETS_API int php_sockets_le_socket(void);
00097 
00098 #define php_sockets_le_socket_name "Socket"
00099 
00100 /* Prototypes */
00101 #ifdef ilia_0 /* not needed, only causes a compiler warning */
00102 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC);
00103 static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC);
00104 static int php_read(php_socket *sock, void *buf, size_t maxlen, int flags);
00105 static char *php_strerror(int error TSRMLS_DC);
00106 #endif
00107 
00108 ZEND_BEGIN_MODULE_GLOBALS(sockets)
00109        int last_error;
00110        char *strerror_buf;
00111 ZEND_END_MODULE_GLOBALS(sockets)
00112 
00113 #ifdef ZTS
00114 #define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v)
00115 #else
00116 #define SOCKETS_G(v) (sockets_globals.v)
00117 #endif
00118 
00119 #else
00120 #define phpext_sockets_ptr NULL
00121 #endif
00122 
00123 #endif
00124 
00125 /*
00126  * Local variables:
00127  * tab-width: 4
00128  * c-basic-offset: 4
00129  * End:
00130  */
00131