continue running script while socket waiting for connection

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Oct 17, 2017 11:38 pm

Wed Oct 18, 2017 11:32 am

Hi guys,

Does anyone know why when creating a socket that listens to connections my scripts doesn`t load until a connection is made ? I simply try to print a message saying "Waiting for connections " after the socket setup is ready, but the text seems to be printed only after a connection is made. I am just using the built-in socket extension.


php-forum Fan User
php-forum Fan User
Posts: 560
Joined: Fri Apr 01, 2016 2:18 am

Wed Oct 18, 2017 10:12 pm

what should happen then? your scripts runs until the end and gets canceled, so does the socket. or your script processes with a socket it can not use, because its not open. PHP does not work async. you may use something like ReactPHP.

Post Reply