Question

it is very first time i'm messing with sockets , and read many quotes that this is not for newbies.

so problem is i'm using php smpp library for sending SMS which works fine but after delivering two to three SMS delivery fails with following warning

Warning: stream_socket_sendto() [function.stream-socket-sendto]: An existing connection was forcibly closed by the remote host', and to make it work again i need to restart` apache.

Following is write function which throwing exception

public function write($buf) {
    $null = null;
    $write = array($this->handle_);

    // keep writing until all the data has been written
    while (strlen($buf) > 0) {
        // wait for stream to become available for writing
        $writable = @stream_select($null, $write, $null, $this->sendTimeoutSec_, $this->sendTimeoutUsec_);
        if ($writable > 0) {
            // write buffer to stream
            $written = stream_socket_sendto($this->handle_, $buf);
            if ($written === -1 || $written === false) {
                throw new TTransportException('TSocket: Could not write '.$written.' bytes '.
                $this->host_.':'.$this->port_);
            }
            // determine how much of the buffer is left to write
            $buf = substr($buf, $written);
        } else if ($writable === 0) {
            throw new TTransportException('TSocket: timed out writing '.strlen($buf).' bytes from '.
            $this->host_.':'.$this->port_);
        } else {
            throw new TTransportException('TSocket: Could not write '.strlen($buf).' bytes '.
            $this->host_.':'.$this->port_);
        }
    }
}

Please anyone can put some light

Was it helpful?

Solution

It was the bug which i won't able to identify/ rectify. then i used an other library from http://www.codeforge.com/read/171085/smpp.php__html and it really saved me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top