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
14
votes
1 answer

HTTP pipelining request text example

Below is an example HTTP 1.1 call with a single page requested : GET /jq.js HTTP/1.1 Host: 127.0.0.1 Accept: */* I understand with HTTP Pipelining, multiple requests can be sent without breaking the connection. Can someone post, some text example…
DMin
  • 10,049
  • 10
  • 45
  • 65
7
votes
2 answers

php stream_get_contents hangs at the end of the stream

Solution at the end of the question I am writing a PHP application that sends a message to a server and then reads a response back in using stream_get_contents. I communicate with the same server in an android app in the same way. The android app…
gb056
  • 149
  • 1
  • 1
  • 7
6
votes
1 answer

fsockopen() how does it actually work?

I am trying to develop a code judge software in PHP for programming assignments. I would try o compile codes on a java server which would require socket programming.I have litle knowledge of socket programming in PHP. I googled and found a code…
shiven
  • 421
  • 2
  • 8
  • 19
5
votes
1 answer

Process socket data with a leading length value

This is a follow-up question about how to process prefixed messages received from a network socket. What I try to do is: Read the first 4 bytes (which is the $prefix and represents the length of the message) Check if $prefix has really the size of…
Mike
  • 1,992
  • 4
  • 31
  • 42
5
votes
2 answers

Sending sockets data with a leading length value

I want to send JSON messages from a PHP script to a C# app over a network connection using PHP Sockets. Usually, for binary protocols, the first 4 bytes of every message must be an integer which represents the length (how many bytes) of the…
Mike
  • 1,992
  • 4
  • 31
  • 42
5
votes
0 answers

Real-time progress of queued jobs laravel at the front end

I am working on Laravel 5.8, and I have a button that starts queue jobs in the database, sending thousands of emails immediately. I want to monitor the progress of the queue on the front-end using a status or progress bar in real-time. I am…
5
votes
1 answer

PHP: stream_socket_server()

I have a homebrew PHP TCP chat server, but it doesn't have a way to detect remote disconnects. I would be grateful if someone knew a way to just take a stream_socket_server() and spit out everything connected to it. Then you could run a loop like…
user1833028
  • 865
  • 1
  • 9
  • 18
4
votes
3 answers

PHP Sockets with SSL / TLS - no suitable shared cipher could be used

I am attempting to create a server and client using PHP Sockets with SSL / TLS. However, when sending data to the server, I receive the following error: PHP Warning: stream_socket_accept(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could…
Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
3
votes
2 answers

Unable to connect to a non-blocking socket

This makes me nuts. I have to create a very simple non-blocking socket script in php 5.3 where a client connects to a server, both using non-blocking sockets. I've tried phpsocketdaemon and the example from the php manual, but in both cases when I…
HomeCoder
  • 2,465
  • 3
  • 18
  • 20
3
votes
2 answers

How to connect telnet and send command and write output into text file using php

i need to telnet to a port and send command and write the output into a txt file using PHP.How i do it? in this forum have a same question name telnet connection using PHP but their have a solution link and the solution link is not open so i have to…
riad
  • 7,144
  • 22
  • 59
  • 70
3
votes
3 answers

PHP NATS Client disconnects after some idle time

I have been using this library repejota/phpnats for developing a NATS Client that can subscribe to a particular channel. But after connecting, receiving few messages and having some 30 secs idle time, it gets disconnect itself without any…
h_h
  • 1,201
  • 4
  • 28
  • 47
3
votes
0 answers

Socket io communicate php

I need communicate php to NodeJs (Socket.io) Server. I find i library about it. But i can't recieve data. The library name is Elephant.io. There is some way to communicate Php and Socket.io ? I need it. I need Send data and Recieve data. This is my…
3
votes
1 answer

Connecting to a ratchet websocket server using PHP

I am running a Ratchet WebSocketServer in my backend this is all working fine.
DB93
  • 610
  • 2
  • 5
  • 16
3
votes
2 answers

Relative path in html with php server

I use php -S localhost:8000 as my development server. At the end I'll use nginx. But I have a problem with php server. root | |---/app | |---/index.html |---/scripts | | | |---/main.css | |---/styles | …
Thomas Sablik
  • 16,127
  • 7
  • 34
  • 62
3
votes
2 answers

How to enable Socket in PHP 5.3.10 on Ubuntu 12.04 System

I am trying to enable Socket in PHP on linux. I checked php.ini but in that file not getting following line. ;extension=php_sockets.so
Sandy8086
  • 653
  • 1
  • 4
  • 14
1
2 3 4 5 6 7