Socket context options

Socket context options — Socket context option listing

说明

Socket context options are available for all wrappers that work oversockets, like tcp, http and ftp. 

可选项

bindto 

Used to specify the IP address (either IPv4 or IPv6) and/or theport number that PHP will use to access the network. The syntaxis ip:port for IPv4 addresses, and [ip]:port for IPv6 addresses.Setting the IP or the port to 0 will let the systemchoose the IP and/or port. 

Note: 

As FTP creates two socket connections during normal operation,the port number cannot be specified using this option. 

backlog 

Used to limit the number of outstanding connections in thesocket's listen queue. 

Note: 

This is only applicable to stream_socket_server(). 

更新日志

版本

说明

5.1.0 Added bindto.  

5.3.3 Added backlog.  

范例

Example #1 Basic bindto usage example

<?php

// connect to the internet using the '192.168.0.100' IP

$opts = array(

    'socket' => array(

        'bindto' => '192.168.0.100:0',

    ),

);

// connect to the internet using the '192.168.0.100' IP and port '7000'

$opts = array(

    'socket' => array(

        'bindto' => '192.168.0.100:7000',

    ),

);

// connect to the internet using the '2001:db8::1' IPv6 address

// and port '7000'

$opts = array(

    'socket' => array(

        'bindto' => '[2001:db8::1]:7000',

    ),

);

// connect to the internet using port '7000'

$opts = array(

    'socket' => array(

        'bindto' => '0:7000',

    ),

);

// create the context...

$context = stream_context_create($opts);

// ...and use it to fetch the data

echo file_get_contents('http://www.example.com', false, $context);

?>  

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

热门产品

php编程基础教程.pptx|php编程培训,php,编程,基础,教程,pptx
php编程基础教程.pptx

历史上的今天:04月27日

PHP魔术常量__DIR__备忘

PHP魔术常量__DIR__备忘概述:本文简要讨论在TP5.0中定义目录常量时,用到的PHP魔术常量__DIR__的含义及其它相关的用法。截止到PHP7.4,通过官方手册查知,目前PHP一共有八个魔术常量,分别为:__LINE__,__FILE__,__DIR__,__FUNCTION__,__CLASS__,__TRAIT__,__METHOD__,__NAMESPACE__。__DIR__ 是

PHP abspath函数代码示例

PHP abspath函数代码示例本文整理汇总了PHP中abspath函数的典型用法代码示例。如果您正苦于以下问题:PHP abspath函数的具体用法?PHP abspath怎么用?PHP abspath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。在下文中一共展示了abspath函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您

热门专题

安徽开放大学|安徽开放大学报名,安徽开放大学报考,安徽开放大学,什么是安徽开放大学,安徽开放大学学历,安徽开放大学学费,安徽开放大学报名条件,安徽开放大学报名时间,安徽开放大学学历,安徽开放大学专业
安徽开放大学
天麻的功效与作用吃法|天麻的功效与作用,天麻的功效与作用吃法,天麻炖什么治头痛最好,天麻的功效与作用禁忌,天麻多少钱一斤,天麻的功效与作用吃法及禁忌,天麻怎么吃效果最好,天麻粉的功效与作用,天麻怎么吃
天麻的功效与作用吃法
小程序开发|微信小程序,小程序开发,小程序,小程序制作,微信小程序开发,小程序公司,小程序开发公司,分销,三级分销系统,分销系统
小程序开发
自考本科|自考本科有用吗,自考文凭,自考本科文凭,自考文凭有用吗,自考本科文凭有用吗,自考文凭承认吗
自考本科
易捷尔单招|易捷尔单招,易捷尔单招培训,易捷尔单招报名,易捷尔单招考试,易捷尔单招培训学校,易捷尔单招分数
易捷尔单招
外贸网站建设|外贸网站建设,英文网站制作,英文网站设计,美国主机空间,外贸建站平台,多语言网站制作
外贸网站建设
云南高职单招|云南单招,云南单招网,云南高职单招网,云南高职单招,云南单招学校,云南单招培训
云南高职单招
金诺幼儿园(春城路金诺幼儿园)|昆明官渡区幼儿园,幼儿园报名,官渡区幼儿园,春城路幼儿园,幼儿园招生,学前班,昆明幼儿园,金诺幼儿园,环城南路幼儿园,石井路幼儿园
金诺幼儿园(春城路金诺幼儿园)

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部