|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[1999-05-25 14:28 UTC] chr at tv2i dot dk
The following code works on PHP3 versions prior to 3.0.7:
$fp = fsockopen('localhost', 25);
echo fgets($fp, 256);
However, on 3.0.8 it appears not to work. Instead the HTTP connection hangs (Apache server status shows mode W even after HTTP connection is closed by the webbrowser).
To make it work on 3.0.8, the following "workaround" can be applied:
$fp = fsockopen('localhost', 25);
set_socket_blocking($fp, 0);
sleep(1);
echo fgets($fp, 256);
The following also works on 3.0.8 (i.e. the connection is closed by the other part):
$fp = fsockopen('localhost', 25);
fputs($fp, "quit\n");
echo fgets($fp, 256);
Loaded modules: mod_php3, mod_setenvif, mod_unique_id, mod_usertrack, mod_headers, mod_cern_meta, mod_auth_anon, mod_auth, mod_access, mod_alias, mod_userdir, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_status, mod_negotiation, mod_mime, mod_mime_magic, mod_log_referer, mod_log_agent, mod_log_config, mod_env, http_core
[PHP_3]
engine = On
short_open_tag = On
asp_tags = On
precision = 14
y2k_compliance = Off
safe_mode = Off
safe_mode_exec_dir =
max_execution_time = 30
memory_limit = 8388608
error_reporting = 7
display_errors = On
log_errors = Off
track_errors = Off
warn_plus_overloading = Off
magic_quotes_gpc = On
magic_quotes_runtime= Off
magic_quotes_sybase = Off
track_vars = On
auto_prepend_file =
auto_append_file =
include_path =
doc_root =
user_dir =
upload_max_filesize = 5000000
extension_dir = ./
[Syslog]
define_syslog_variables = Off
[mail function]
SMTP = localhost
sendmail_from = me@localhost.com
sendmail_path =
[Debugger]
debugger.host = localhost
debugger.port = 7869
debugger.enabled = False
[SQL]
sql.safe_mode = Off
[bcmath]
bcmath.scale = 0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 13:00:02 2026 UTC |
You want blocking behaviour: $fp = fsockopen("localhost", 25); set_socket_blocking($fp, true); echo fgets($fp, 512); fputs($fp, "quit\r\n"); echo fgets($fp, 512);