Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 25th, 2004, 08:08 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Basilar problems in programmming with socket

Hi everyone,
first of all sorry for my bad English
I've started programming with socket in php (yes, I'm a newbie) and I've already a problem which doesn't allow me to go forward.
Hope you can help me...
I've tried to use the entire code token from the article called 'Socket Programming With PHP' but it doesn't work properly under win xp.
It comes out this error
-- Warning: socket_bind() unable to bind address [10048]: Di norma è consentito un solo utilizzo di ogni indirizzo di socket (protocollo/indirizzo di rete/porta). in c:\programmi\apache group\apache\htdocs\test\socket\socket.php3 on line 14
Could not bind to socket

Total translation should be:
-- Warning: socket_bind() unable to bind address [10048]: basely it is allowed a unique address of socket (protocol/network address/port). in c:\programmi\apache group\apache\htdocs\test\socket\socket.php3 on line 14
Could not bind to socket

Here the configuration: apache/1.3.27 (Win32) PHP/4.3.4

Here the code:
--- socket.php3 ---
<?

// set some variables
$host = "127.0.0.1";
$port = 1234;

// don't timeout!
set_time_limit(0);

// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create
socket\n");

// bind socket to port
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");

// start listening for connections
$result = socket_listen($socket, 3) or die("Could not set up socket
listener\n");

// accept incoming connections
// spawn another socket to handle communication
$spawn = socket_accept($socket) or die("Could not accept incoming
connection\n");

// read client input
$input = socket_read($spawn, 1024) or die("Could not read input\n");

// clean up input string
$input = trim($input);

// reverse client input and send back
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output)) or die("Could not write
output\n");

// close sockets
socket_close($spawn);
socket_close($socket);
?>

Thanks a lot to all in advance!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket Progrmming sudhirbharti C# 2005 2 February 21st, 2008 03:54 AM
Socket connections hockney General .NET 1 July 6th, 2005 04:14 AM
Socket Programming ashu_from_india General .NET 0 June 28th, 2005 12:02 PM
Socket programming vinodkalpaka J2EE 0 June 16th, 2005 02:43 AM
Socket Programming chinni Pro PHP 1 August 18th, 2003 03:59 PM



All times are GMT -4. The time now is 02:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.