/** * connect * * Connect the socket * * @return bool */ function connect() { $result = $this->Serial->deviceOpen("w+b"); if ($result === false) { throw new Exception("serrial.open() failed"); } if ($this->debug) { echo "Connected\n"; } stream_set_timeout($this->Serial->_dHandle, 0, 250000); MySensorMaster::connect(); return true; }
/** * connect * * Connect the socket * * @return bool */ function connect() { // TCP socket $this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_set_option($this->sock, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 1, 'usec' => 0)); socket_set_option($this->sock, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 0, "usec" => 250000)); // Connect the socket $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))); } if ($this->debug) { echo "Connected\n"; } MySensorMaster::connect(); return true; }
/** * connect * * Connect the socket * * @return bool */ function connect() { if ($this->debug) { echo date("Y-m-d H:i:s") . " Connecting TCP\n"; } // TCP socket $this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_set_option($this->sock, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 0, 'usec' => 200000)); socket_set_option($this->sock, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 0, "usec" => 250000)); socket_set_option($this->sock, SOL_SOCKET, SO_KEEPALIVE, 1); // Connect the socket $result = @socket_connect($this->sock, $this->host, $this->port); if ($result === false) { echo "socket_connect() failed. Reason: " . socket_strerror(socket_last_error($this->sock)) . "\n"; return $result; } if ($this->debug) { echo date("Y-m-d H:i:s") . " Connected\n"; } MySensorMaster::connect(); return true; }