Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP Manual > socket_set_option - Sets socket options for the socket





ลองใช้ค้นหาข้อมูล


   
Bookmark.

socket_set_option

(PHP 4 >= 4.3.0, PHP 5)

socket_set_optionSets socket options for the socket

Description

bool socket_set_option ( resource $socket , int $level , int $optname , mixed $optval )

The socket_set_option() function sets the option specified by the optname parameter, at the specified protocol level , to the value pointed to by the optval parameter for the socket .

Parameters

socket

A valid socket resource created with socket_create() or socket_accept().

level

The level parameter specifies the protocol level at which the option resides. For example, to retrieve options at the socket level, a level parameter of SOL_SOCKET would be used. Other levels, such as TCP, can be used by specifying the protocol number of that level. Protocol numbers can be found by using the getprotobyname() function.

optname

The available socket options are the same as those for the socket_get_option() function.

optval

The option value.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 socket_set_option() example

<?php
$socket 
socket_create(AF_INETSOCK_STREAMSOL_TCP);

if (!
is_resource($socket)) {
    echo 
'Unable to create socket: 'socket_strerror(socket_last_error()) . PHP_EOL;
}

if (!
socket_set_option($socketSOL_SOCKETSO_REUSEADDR1)) {
    echo 
'Unable to set option on socket: 'socket_strerror(socket_last_error()) . PHP_EOL;
}

if (!
socket_bind($socket'127.0.0.1'1223)) {
    echo 
'Unable to bind socket: 'socket_strerror(socket_last_error()) . PHP_EOL;
}

$rval socket_get_option($socketSOL_SOCKETSO_REUSEADDR);

if (
$rval === false) {
    echo 
'Unable to get socket option: 'socket_strerror(socket_last_error()) . PHP_EOL;
} else if (
$rval !== 0) {
    echo 
'SO_REUSEADDR is set on socket !' PHP_EOL;
}
?>

ChangeLog

Version Description
4.3.0 This function was renamed. It used to be called socket_setopt().



ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่