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

1928 у кіно

Захаров Федір Захарович

Ель Греко