Problem with closing a client socket in php The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow to get useful error messages in PHP?How can I prevent SQL injection in PHP?PHP: Delete an element from an arrayHow do I get PHP errors to display?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?Fatal error: Call to undefined function socket_create()PHP Socket issue - disconnect immediately after connectingHow does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Will I lose my paid in full property

Why aren't road bicycle wheels tiny?

What's parked in Mil Moscow helicopter plant?

What is the numbering system used for the DSN dishes?

Test if all elements of a Foldable are the same

Where to find documentation for `whois` command options?

Why would the Overseers waste their stock of slaves on the Game?

Is a self contained air-bullet cartridge feasible?

What do you call an IPA symbol that lacks a name (e.g. ɲ)?

Was Objective-C really a hindrance to Apple software development?

Bright yellow or light yellow?

When speaking, how do you change your mind mid-sentence?

What's called a person who works as someone who puts products on shelves in stores?

Is there a possibility to generate a list dynamically in Latex?

Arriving in Atlanta (after US Preclearance in Dublin). Will I go through TSA security in Atlanta to transfer to a connecting flight?

Married in secret, can marital status in passport be changed at a later date?

Could a cockatrice have parasitic embryos?

Why did Israel vote against lifting the American embargo on Cuba?

Eigenvalues of the Laplacian of the directed De Bruijn graph

RIP Packet Format

What is /etc/mtab in Linux?

`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY

Determinant of a matrix with 2 equal rows

How to translate "red flag" into Spanish?



Problem with closing a client socket in php



The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow to get useful error messages in PHP?How can I prevent SQL injection in PHP?PHP: Delete an element from an arrayHow do I get PHP errors to display?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?Fatal error: Call to undefined function socket_create()PHP Socket issue - disconnect immediately after connectingHow does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I tried to write a PHP project to communicate with a PLC, but I have a problem when I close a socket client, it didn't close immediately, connected devices increase when I call an AJAX function to reload values, can anyone help me? I use RS_sim to simulate PLC



my page



My code to create and close socket client:



private function connect()
// Create a protocol specific socket
if ($this->socket_protocol == "TCP")
// TCP socket
$this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);


$result = @socket_connect($this->sock, $this->host, $this->port);
if ($result === false)
throw new Exception("socket_connect() failed.</br>Reason: ($result)".
socket_strerror(socket_last_error($this->sock)));
else
$this->status .= "Connectedn";
return true;


private function disconnect()
socket_close($this->sock);
$this->status .= "Disconnectedn";








share
























  • Did you get any error message for socket_close? If not in PHP, then in the simulator? Is this a long running script, or just a one-off connection? (Possibly also try strace to inspect your running script.)

    – mario
    Mar 9 at 4:45











  • Does the server expect you to send a command to close the connection? Closing the connection in the client without a message to the server might not be enough

    – Joni
    Mar 9 at 5:18












  • Thanks for your supports,mario and Joni, I will try with a real PLC

    – tidibi272
    Mar 9 at 7:04

















1















I tried to write a PHP project to communicate with a PLC, but I have a problem when I close a socket client, it didn't close immediately, connected devices increase when I call an AJAX function to reload values, can anyone help me? I use RS_sim to simulate PLC



my page



My code to create and close socket client:



private function connect()
// Create a protocol specific socket
if ($this->socket_protocol == "TCP")
// TCP socket
$this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);


$result = @socket_connect($this->sock, $this->host, $this->port);
if ($result === false)
throw new Exception("socket_connect() failed.</br>Reason: ($result)".
socket_strerror(socket_last_error($this->sock)));
else
$this->status .= "Connectedn";
return true;


private function disconnect()
socket_close($this->sock);
$this->status .= "Disconnectedn";








share
























  • Did you get any error message for socket_close? If not in PHP, then in the simulator? Is this a long running script, or just a one-off connection? (Possibly also try strace to inspect your running script.)

    – mario
    Mar 9 at 4:45











  • Does the server expect you to send a command to close the connection? Closing the connection in the client without a message to the server might not be enough

    – Joni
    Mar 9 at 5:18












  • Thanks for your supports,mario and Joni, I will try with a real PLC

    – tidibi272
    Mar 9 at 7:04













1












1








1








I tried to write a PHP project to communicate with a PLC, but I have a problem when I close a socket client, it didn't close immediately, connected devices increase when I call an AJAX function to reload values, can anyone help me? I use RS_sim to simulate PLC



my page



My code to create and close socket client:



private function connect()
// Create a protocol specific socket
if ($this->socket_protocol == "TCP")
// TCP socket
$this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);


$result = @socket_connect($this->sock, $this->host, $this->port);
if ($result === false)
throw new Exception("socket_connect() failed.</br>Reason: ($result)".
socket_strerror(socket_last_error($this->sock)));
else
$this->status .= "Connectedn";
return true;


private function disconnect()
socket_close($this->sock);
$this->status .= "Disconnectedn";








share
















I tried to write a PHP project to communicate with a PLC, but I have a problem when I close a socket client, it didn't close immediately, connected devices increase when I call an AJAX function to reload values, can anyone help me? I use RS_sim to simulate PLC



my page



My code to create and close socket client:



private function connect()
// Create a protocol specific socket
if ($this->socket_protocol == "TCP")
// TCP socket
$this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);


$result = @socket_connect($this->sock, $this->host, $this->port);
if ($result === false)
throw new Exception("socket_connect() failed.</br>Reason: ($result)".
socket_strerror(socket_last_error($this->sock)));
else
$this->status .= "Connectedn";
return true;


private function disconnect()
socket_close($this->sock);
$this->status .= "Disconnectedn";






php websocket plc





share














share












share



share








edited Mar 10 at 21:46









GregP

8211




8211










asked Mar 9 at 4:36









tidibi272tidibi272

61




61












  • Did you get any error message for socket_close? If not in PHP, then in the simulator? Is this a long running script, or just a one-off connection? (Possibly also try strace to inspect your running script.)

    – mario
    Mar 9 at 4:45











  • Does the server expect you to send a command to close the connection? Closing the connection in the client without a message to the server might not be enough

    – Joni
    Mar 9 at 5:18












  • Thanks for your supports,mario and Joni, I will try with a real PLC

    – tidibi272
    Mar 9 at 7:04

















  • Did you get any error message for socket_close? If not in PHP, then in the simulator? Is this a long running script, or just a one-off connection? (Possibly also try strace to inspect your running script.)

    – mario
    Mar 9 at 4:45











  • Does the server expect you to send a command to close the connection? Closing the connection in the client without a message to the server might not be enough

    – Joni
    Mar 9 at 5:18












  • Thanks for your supports,mario and Joni, I will try with a real PLC

    – tidibi272
    Mar 9 at 7:04
















Did you get any error message for socket_close? If not in PHP, then in the simulator? Is this a long running script, or just a one-off connection? (Possibly also try strace to inspect your running script.)

– mario
Mar 9 at 4:45





Did you get any error message for socket_close? If not in PHP, then in the simulator? Is this a long running script, or just a one-off connection? (Possibly also try strace to inspect your running script.)

– mario
Mar 9 at 4:45













Does the server expect you to send a command to close the connection? Closing the connection in the client without a message to the server might not be enough

– Joni
Mar 9 at 5:18






Does the server expect you to send a command to close the connection? Closing the connection in the client without a message to the server might not be enough

– Joni
Mar 9 at 5:18














Thanks for your supports,mario and Joni, I will try with a real PLC

– tidibi272
Mar 9 at 7:04





Thanks for your supports,mario and Joni, I will try with a real PLC

– tidibi272
Mar 9 at 7:04












0






active

oldest

votes


















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved