Aborting a socket accept() after X seconds
-
Hello Is it possible to abort a socket accept after X seconds? I got two classes: cfiletransferserver and cfiletransferclient. I launch a cfiletransferserver on a specific port and than send the port to my client application. The client application then tries to connect to the server by using cfiletransferclient. cfiletransferserver deletes itself from the stack when the filetransfer is finished. I want cfiletransferserver to delete itself if no cfiletransferclient have connected to it in X seconds. How do I do that? Thanks, Jonas
-
Hello Is it possible to abort a socket accept after X seconds? I got two classes: cfiletransferserver and cfiletransferclient. I launch a cfiletransferserver on a specific port and than send the port to my client application. The client application then tries to connect to the server by using cfiletransferclient. cfiletransferserver deletes itself from the stack when the filetransfer is finished. I want cfiletransferserver to delete itself if no cfiletransferclient have connected to it in X seconds. How do I do that? Thanks, Jonas
Instead of calling
accept()
for the listening socket, callselect()
. Select will block the thread until an event happens on the socket, ie. a connection is ready. The second parameter of theselect()
function is a TIMEVAL structure which can specify a timeout. The return value of theselect()
call specifies whether a timeout occurred or a connection was receivied, ready to accept usingaccept()
. Look at the docs for more info. Hope this helps Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact" -
Instead of calling
accept()
for the listening socket, callselect()
. Select will block the thread until an event happens on the socket, ie. a connection is ready. The second parameter of theselect()
function is a TIMEVAL structure which can specify a timeout. The return value of theselect()
call specifies whether a timeout occurred or a connection was receivied, ready to accept usingaccept()
. Look at the docs for more info. Hope this helps Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"