ถ้าจากโค๊ดนี้
<?php
$host = "192.168.1.40";
$port = 1234;
// don't timeout!
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, 0)
or die("Could not create socket\n");
$socket = socket_create(AF_INET, SOCK_DGRAM, 0)
or die("Could not create socket\n");
$result = socket_bind($socket, $host, $port)
or die("Could not bind to socket\n");
$result = socket_listen($socket, 3)
or die("Could not set up socket listener\n");
$spawn = socket_accept($socket)
or die("Could not accept incoming connection\n");
$input = socket_read($spawn, 1024) or die("Could not read input\n");
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output))
or die("Could not write output\n");
socket_close($spawn);
socket_close($socket);
?>
แต่ว่ารันผ่าน firefox แล้ว
http://localhost/webpage/testsocket.php
ฟ้องว่า
Warning: socket_listen() [function.socket-listen]: unable to listen on socket [0]: The attempted operation is not supported for the type of object referenced. in C:\AppServ\www\webPage\testsocket.php on line 17
Could not set up socket listener
* จุดประสงค์ของเราคือ ต้องการเขียน php เป็นฟังก์ชันเปิดพอร์ตไว้ รอการตอบรับจากคอมอีกเครื่องนึง
และตัว php จะถูกรันเมื่อกดปุ๋ม ผ่านทางเว็บที่เขียนโดย HTML อะ
ปล. เค้าคิดว่า เค้าอาจจะเช้าใจตรง host ผิดแน่ๆเลย หรือต้องติดตั้งอะไรผิด ยังไงแนะนำหน่อยคะ