2000-07-03 04:35:57 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-08 17:33:29 +00:00
|
|
|
| PHP Version 5 |
|
2000-07-03 04:35:57 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 09:36:18 +00:00
|
|
|
| Copyright (c) 1997-2007 The PHP Group |
|
2000-07-03 04:35:57 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-07-03 04:35:57 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-07-03 04:35:57 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2000-08-20 10:31:27 +00:00
|
|
|
| Authors: Chris Vandomelen <chrisv@b0rked.dhs.org> |
|
2001-05-17 17:02:37 +00:00
|
|
|
| Sterling Hughes <sterling@php.net> |
|
|
|
|
| |
|
|
|
|
| WinSock: Daniel Beulshausen <daniel@php4win.de> |
|
2000-07-03 04:35:57 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2000-07-03 06:45:07 +00:00
|
|
|
#ifndef PHP_SOCKETS_H
|
|
|
|
#define PHP_SOCKETS_H
|
2000-07-03 04:35:57 +00:00
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#if HAVE_SOCKETS
|
|
|
|
|
|
|
|
extern zend_module_entry sockets_module_entry;
|
|
|
|
#define phpext_sockets_ptr &sockets_module_entry
|
|
|
|
|
|
|
|
#ifdef PHP_WIN32
|
|
|
|
#define PHP_SOCKETS_API __declspec(dllexport)
|
2001-11-01 22:40:43 +00:00
|
|
|
#include <winsock.h>
|
2000-07-03 04:35:57 +00:00
|
|
|
#else
|
|
|
|
#define PHP_SOCKETS_API
|
2001-11-06 14:35:26 +00:00
|
|
|
#if HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
2000-07-03 04:35:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
PHP_MINIT_FUNCTION(sockets);
|
|
|
|
PHP_MINFO_FUNCTION(sockets);
|
2002-09-30 02:09:42 +00:00
|
|
|
PHP_RSHUTDOWN_FUNCTION(sockets);
|
2000-07-03 04:35:57 +00:00
|
|
|
|
2001-05-17 17:02:37 +00:00
|
|
|
PHP_FUNCTION(socket_select);
|
|
|
|
PHP_FUNCTION(socket_create_listen);
|
2007-07-22 23:01:20 +00:00
|
|
|
#ifdef HAVE_SOCKETPAIR
|
2001-05-17 17:02:37 +00:00
|
|
|
PHP_FUNCTION(socket_create_pair);
|
2007-07-22 23:01:20 +00:00
|
|
|
#endif
|
2001-05-17 17:02:37 +00:00
|
|
|
PHP_FUNCTION(socket_accept);
|
|
|
|
PHP_FUNCTION(socket_set_nonblock);
|
2002-03-06 05:21:56 +00:00
|
|
|
PHP_FUNCTION(socket_set_block);
|
2001-05-17 17:02:37 +00:00
|
|
|
PHP_FUNCTION(socket_listen);
|
|
|
|
PHP_FUNCTION(socket_close);
|
|
|
|
PHP_FUNCTION(socket_write);
|
|
|
|
PHP_FUNCTION(socket_read);
|
|
|
|
PHP_FUNCTION(socket_getsockname);
|
|
|
|
PHP_FUNCTION(socket_getpeername);
|
|
|
|
PHP_FUNCTION(socket_create);
|
|
|
|
PHP_FUNCTION(socket_connect);
|
|
|
|
PHP_FUNCTION(socket_strerror);
|
|
|
|
PHP_FUNCTION(socket_bind);
|
|
|
|
PHP_FUNCTION(socket_recv);
|
|
|
|
PHP_FUNCTION(socket_send);
|
|
|
|
PHP_FUNCTION(socket_recvfrom);
|
|
|
|
PHP_FUNCTION(socket_sendto);
|
2002-05-01 11:08:08 +00:00
|
|
|
PHP_FUNCTION(socket_get_option);
|
|
|
|
PHP_FUNCTION(socket_set_option);
|
2007-01-10 15:25:07 +00:00
|
|
|
#ifdef HAVE_SHUTDOWN
|
2001-05-17 17:02:37 +00:00
|
|
|
PHP_FUNCTION(socket_shutdown);
|
2007-01-10 15:25:07 +00:00
|
|
|
#endif
|
2001-11-01 16:51:59 +00:00
|
|
|
PHP_FUNCTION(socket_last_error);
|
2002-03-06 05:21:56 +00:00
|
|
|
PHP_FUNCTION(socket_clear_error);
|
2000-08-20 10:31:27 +00:00
|
|
|
|
2001-07-25 22:03:55 +00:00
|
|
|
#ifndef PHP_WIN32
|
2003-06-17 04:44:30 +00:00
|
|
|
typedef int PHP_SOCKET;
|
|
|
|
#else
|
|
|
|
typedef SOCKET PHP_SOCKET;
|
2001-05-17 17:02:37 +00:00
|
|
|
#endif
|
2001-07-25 22:03:55 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2003-06-17 04:44:30 +00:00
|
|
|
PHP_SOCKET bsd_socket;
|
2001-07-25 22:03:55 +00:00
|
|
|
int type;
|
2001-11-01 16:51:59 +00:00
|
|
|
int error;
|
2007-07-22 23:01:20 +00:00
|
|
|
int blocking;
|
2001-05-17 17:02:37 +00:00
|
|
|
} php_socket;
|
|
|
|
|
2001-11-01 22:40:43 +00:00
|
|
|
/* Prototypes */
|
2003-05-28 01:04:06 +00:00
|
|
|
#ifdef ilia_0 /* not needed, only causes a compiler warning */
|
2003-04-17 23:18:58 +00:00
|
|
|
static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC);
|
|
|
|
static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC);
|
2007-07-22 23:01:20 +00:00
|
|
|
static int php_read(php_socket *sock, void *buf, size_t maxlen, int flags);
|
2003-04-17 23:18:58 +00:00
|
|
|
static char *php_strerror(int error TSRMLS_DC);
|
2003-05-28 01:04:06 +00:00
|
|
|
#endif
|
2001-11-01 22:40:43 +00:00
|
|
|
|
2002-04-29 14:52:29 +00:00
|
|
|
ZEND_BEGIN_MODULE_GLOBALS(sockets)
|
2002-09-30 02:09:42 +00:00
|
|
|
int last_error;
|
|
|
|
char *strerror_buf;
|
2002-04-29 14:52:29 +00:00
|
|
|
ZEND_END_MODULE_GLOBALS(sockets)
|
|
|
|
|
2000-07-03 04:35:57 +00:00
|
|
|
#ifdef ZTS
|
2002-04-29 14:52:29 +00:00
|
|
|
#define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v)
|
2000-07-03 04:35:57 +00:00
|
|
|
#else
|
2002-04-29 14:52:29 +00:00
|
|
|
#define SOCKETS_G(v) (sockets_globals.v)
|
2000-07-03 04:35:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define phpext_sockets_ptr NULL
|
|
|
|
#endif
|
|
|
|
|
2001-05-17 17:02:37 +00:00
|
|
|
#endif
|
2000-07-03 04:35:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
2001-05-21 19:36:22 +00:00
|
|
|
*/
|
|
|
|
|