Re: How to cancel select() call ?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Because that would defeat the whole purpose of his hack...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> wrote in message
news:%23TRhZE7mHHA.4412@xxxxxxxxxxxxxxxxxxxxxxx
Why you need to release before select(), do it after exactly when you
don't need it
Arkady

"kamil" <kamildobk@xxxxxxxxxxxxxxxxx> wrote in message
news:u8U%23E26mHHA.960@xxxxxxxxxxxxxxxxxxxxxxx
I have to release any mutex before I enter select() and during that time,
after releasing mutex and before entering select(), socket can be closed
by my application because of an event, and immediately after that another
socket, with the same descriptor, can be created by other thread / there
are a few, completely independent threads, which create sockets in my
application /, and that / random / socket will be added to select().

Kamil

U¿ytkownik "Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> napisa³ w
wiadomo¶ci news:OZbAb65mHHA.568@xxxxxxxxxxxxxxxxxxxxxxx
Why ? "after select() exits and before I create disposable socket again
there is a time when socket descriptor will be invalid." - is place for
mutex and OTOH use the same mutex to enter the code which create socket
Arkady

"kamil" <kamildobk@xxxxxxxxxxxxxxxxx> wrote in message
news:%234$xQP4mHHA.4624@xxxxxxxxxxxxxxxxxxxxxxx
But there is no good place to put that mutex - in this case I won't
close any socket by accident but, instead of this, I can add a random
socket to select() set.

Kamil


U¿ytkownik "Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> napisa³ w
wiadomo¶ci news:ezSHSXqmHHA.568@xxxxxxxxxxxxxxxxxxxxxxx
Use sync object ( mutex ) in this case to allow main thread to
reallocate
socket before other thread will try to do the same
Arkady

"kamil" <kamildobk@xxxxxxxxxxxxxxxxx> wrote in message
news:en7llYkmHHA.5024@xxxxxxxxxxxxxxxxxxxxxxx
I found some cross-platform network library for RTP/RTCP protocol. It
works well, but I have one problem - it uses select() in its main
loop. I need a way to cancel select() call from another thread as
fast as possible when some events in my application are invoked ( to
make a new connection ). I know that I can add 'disposable socket' to
a socket set and close it when I want select to be cancelled, but I'm
not sure if it is completely safe method. Lets say my event loop looks
like this:

create_disposable_socket()
while()
{
select()
if ( myevent ) <--------------------- insafe, socket descriptor
invalid ?????
{
create_disposable_socket_again();
handle_my_app_events()
}
else
{
handle_network_events();
}
}

But after select() exits and before I create disposable socket again
there is a time when socket descriptor will be invalid. What if some
other thread create socket which reuse the same descriptor - it can
be closed because my application thread still thinks that it is a
disposable socket created to cancel select !
Is it possible or am I missing something ?

Thanks you in advance,
Kamil













.



Relevant Pages

  • Re: URL filtering using LSP
    ... Microsoft MVP, MCSD ... E.g. in your WSPRecv implementation. ... mark the socket as readable and return your own response ... If you want to close the socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to correctly disconnect timeouted clients in IOCP server?
    ... then your last resort is to close the socket and open ... Alexander Nickolov ... Microsoft MVP, MCSD ...
    (microsoft.public.win32.programmer.networks)
  • Re: WSARecv call blocking when using overlapped I/O
    ... That's because Win9x doesn't feature overlapped I/O. ... Alexander Nickolov ... >> You need an overlapped socket for overlapped I/O. ... >> Microsoft MVP, MCSD ...
    (microsoft.public.win32.programmer.networks)
  • Re: WSAENOBUFS error with recv
    ... receive window on Win 2K/XP is 64K... ... Microsoft MVP, MCSD ... >>> PJ> receive a huge amount of data in a single call to recv. ... >> then I would consider changing the recv socket buffer size. ...
    (microsoft.public.win32.programmer.networks)
  • Re: UDP packets receiving...
    ... Microsoft MVP, MCSD ... yes i realized that it is already a blocking function and i wrapped it ... non blocking or blocking socket code:- ... will return the total number of bytes waiting to be read from ...
    (microsoft.public.win32.programmer.networks)