Hi,<br> In my asterisk application app_myApplication() code, I have to bind a socket to a dynamic port number, so that I can send/receive some strings. I am able to get it working by below code.<br><br>Now the problem is; say the read timeout of socket is 60 secs and user hangs up the channel in 30 seconds, Call is disconnected but still app_myApplication() remains for that channel and when 60 seconds have passed. Then normal application follow is executed and channel closes gracefully. <br>

<br>Is there any way that I can terminate the socket along with channel hangup event ?<br><br>///------------------------------ CODE -----------------------------------------<br>    int sockfd, new_fd;  // listen on sock_fd<br>

    struct sockaddr_in my_addr;    // my address information<br>    struct sockaddr_in their_addr; // connector&#39;s address information<br>    socklen_t sin_size;<br><br>    struct timeval tv;<br><br>    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {<br>

        return -1; <br>    }<br>    <br>    my_addr.sin_family = AF_INET;         // host byte order<br>    my_addr.sin_port = htons(atoi(port));     // short, network byte order<br>    my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP<br>

    memset(my_addr.sin_zero, &#39;\0&#39;, sizeof my_addr.sin_zero);<br><br>    if (bind(sockfd, (struct sockaddr *)&amp;my_addr, sizeof my_addr) == -1) {<br>        return -1;<br>    }<br><br>    if (listen(sockfd, BACKLOG) == -1) {<br>

        return -1;<br>    }<br><br>// HERE I am setting the socket Read time out<br><br>    tv.tv_sec = 60;<br>    tv.tv_usec = 0;<br><br>    if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &amp;tv, sizeof tv) == -1) {<br>

        return -1;<br>    }<br><br>///------------------------------ CODE -----------------------------------------<br><br><br><font color="#888888">/ag</font><br><font color="#888888">
</font><br>