?
Solved

Trying to create PHP Socket Server and test using Apache but socket binding problem!

Posted on 2008-06-11
1
Medium Priority
?
2,038 Views
Last Modified: 2013-12-13
So I've created a PHP based socket server and I just installed XAMMP so I have Apache, PHP, everything running locally.

Now when I try to run my socket server, I get the following error:

Warning: socket_bind() [function.socket-bind]: unable to bind address [0]: Only one usage of each socket address (protocol/network address/port) is normally permitted.

Here is the code:

<?php

// Set time limit to indefinite execution
set_time_limit (0);

// Set the ip and port we will listen on
$address = 'xxx.xxx.xxx.xxx';
$port = 9000;
$max_readers = 10;

// Array that will hold reader information
$client = array();

// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
// Bind the socket to an address/port
socket_bind($sock, $address, $port) or die('Could not bind to address');


The error is on that last line. I figure that it's because Apache is already listening on that port for incoming connections thus the reason why I cannot bind to it.

So my question is, how can I get Apache to NOT look at that port so I can use it for other incoming data?
0
Comment
Question by:TheFuteballer
1 Comment
 
LVL 1

Accepted Solution

by:
TheFuteballer earned 0 total points
ID: 21765580
nevermind, turned out port 9000 was no good for some reason
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month16 days, 3 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question