Questions tagged [php-socket]

PHP comes with a very capable socket programming API. These socket functions include almost everything you would need for socket-based client-server communication over TCP/IP, and can be easily deployed to build simple network applications.

More info here: https://php.net/manual/en/book.sockets.php

96 questions
1
vote
1 answer

PHP socket Connection refused (Java server)

I have a working Java socket, but I need some help connecting to it with PHP. My problem: I can connect to the Java socket from a Java client and send/receive messages, but when I try to connect to the same socket with PHP, it won't connect. This is…
Parker Jones
  • 83
  • 2
  • 10
1
vote
1 answer

PHP: Can pcntl_alarm() and socket_select() peacefully exist in the same thread?

I have a PHP CLI script mostly written that functions as a chat server for chat clients to connect to (don't ask me why I'm doing it in PHP, thats another story haha). My script utilizes the socket_select() function to hang execution until…
DWilliams
  • 451
  • 8
  • 22
1
vote
1 answer

socket_bind() : Only one usage of each socket address (protocol/network address/port) is normally permitted in php

I have copied Client/Server Socket Program from the following source http://www.php.net/manual/en/sockets.examples.php but when i run it in my browser it gives following error message: socket_bind() reason: Only one usage of each socket address…
user3812616
  • 11
  • 1
  • 7
1
vote
1 answer

PHP socket server closes when connect client to server

I'm coding a php socket server script which is running on ubuntu. It works well, clients can connect/disconnect to this server. But the server is shutting down silently when a client connect to this server that didn't have any client connected for a…
Ex.
  • 11
  • 3
1
vote
1 answer

Exception not handled in correct method using PhpUnit

I'm trying to create a library for a personal project using php sockets. For that I started using phpUnit, to learn and to write a (more or less) qualitative library. When i don't provide the try/catch block in the testConnection method, php gives…
glenz0r
  • 53
  • 7
1
vote
1 answer

How do I send a control character down a socket in PHP?

In a PHP script I am writing, I need to send a control+z character down a network socket I have previously created. I understand the ctrl+z character to be chr(26), so at the end of the string I am sending I have added a new line (\r\n) and then the…
JonTheNiceGuy
  • 601
  • 8
  • 23
1
vote
0 answers

How to set up wordpress in subdir with php-fpm on unix socket?

I want to migrate my wordpress installation from apache to nginx. Actually everything is working (at least it seems so) but the rewriting of urls. My setup: php-fpm on unix instead tcp socket wordpress installation in /var/www/blog/ ubuntu 12.04…
boop
  • 7,413
  • 13
  • 50
  • 94
1
vote
3 answers

Unable to capture response of PHP Sockets Connection :: 504 Gateway Time-out

I am using the following php code to connect and send a request to a remote server through php sockets connection. test"; echo "Message To server :".$message; // create…
1
vote
1 answer

Passing data to a system through socket using PHP

I have the below sample data stream, which has to be transmitted to a system, through socket programming. This stream is generated from db. Every 243 char I get a new stream. > 0243P254NIP40524KCK0240000000104844200001 >…
Mani
  • 169
  • 1
  • 3
  • 16
1
vote
1 answer

PHP Sockets: From php server to web client

I have a php socket server that I use to handle messages from a modem. I want to create a php websocket server and whenever I receive a message from the modem I send it to a webclient. I'm a couple days trying to do it without success. How is the…
Giovanne Afonso
  • 666
  • 7
  • 21
1
vote
2 answers

read single byte as an unsigned byte

I have some a java server that I'm trying to get to play with a php script. The format provides the number of bytes the message will take as an unsigned byte, and then the bytes that comprise the string. here's my function with commentary function…
corsiKa
  • 81,495
  • 25
  • 153
  • 204
0
votes
1 answer

PHP socket not working properly

I have established a server to listen to incoming requests through port 1122 on my 127.0.0.1 Here is my code :
Momo
  • 523
  • 3
  • 11
  • 23
0
votes
0 answers

How can I receive and send multiple messages with PHP sockets?

I am just playing with PHP sockets for fun. I am trying to implement a messaging service. I've been able to connect multiple client to the server but I can't receive all of the messages that I'm expecting. my…
0
votes
0 answers

How to fix too much time taken by python requests during get and post?

There is one website written in CakePhp and I am moving to Django. Some pages are making get/post request to another website to collect some information. CakePhp $start = time(); $socket = new HttpSocket(); $api_ret =…
0
votes
1 answer

PHP7 issue : socket_sendto occurred "Unknown host"

Q : Please let i know why socket_sendto function occurred Unknown host error env centos 7.9 php-fpm 7.4 AND php-fpm 8.1 in docker container /etc/hosts 127.0.0.1 nd.domain.com execution php -q…