Solved

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

Posted on 2008-06-11
1
2,000 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

948 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now