PHP Sockets on XAMPP Server problems?
-
here is my code: <?php $PORT = 9001; //the port on which we are connecting to the "remote" machine $HOST = 'localhost'; //the ip of the remote machine (in this case it's the same machine) $sock = socket_create(AF_INET, SOCK_STREAM, 0) //Creating a TCP socket or die("error: could not create socket\n"); $succ = socket_connect($sock, $HOST, $PORT) //Connecting to to server using that socket or die("error: could not connect to host\n"); $text = "Hello, Java!"; //the text we want to send to the server socket_write($sock, $text."\n", strlen($text) + 1) //Writing the text to the socket or die("error: failed to write to socket\n"); $reply = socket_read($sock, 10000, PHP_NORMAL_READ) //Reading the reply from socket or die("error: failed to read from socket\n"); echo $reply; ?> and i always get an error message and never able to successfully establish the socket connection Warning: socket_connect() [function.socket-connect]: unable to connect [0]: No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\socket\index.php on line 8 error: could not connect to host any help will do. thanks in advance.
-
Answer:
is something running on Port 9001 on the host that can accept the socket? XAMPP default installation opens up 80 and 443 for accepting traffic, in order for it to accept traffic on 9001 you would have to modify the port in the httpd.conf in /opt/lampp/etc/ or httpd-ssl.conf in /opt/lampp/etc/extra You can create another config in $XAMPPROOT/etc/extra and use the $include in $XAMPPROOT/etc/httpd.conf that includes the directive to use port 9001. The issue is with the web server..
jackerx_... at Yahoo! Answers Visit the source
Related Q & A:
- How to upload a file to another server using cURL and PHP?Best solution by Stack Overflow
- What is the difference between application server and web server?Best solution by Server Fault
- How to store data in php and get data from php?Best solution by Stack Overflow
- Is there any problem with the yahoo messenger server in the us, having problems loging in?Best solution by Yahoo! Answers
- How do I monitor the activity of sockets?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.