Shutdown Listening socket (win socket 2 - vs 1)

Shutdown Listening socket (win socket 2 - vs 1)

Post by Jiannis » Tue, 03 Dec 2002 19:22:37



In my server - side TCP /IP application , I create a listening blocking
socket.
The WSAAccept is called from a different thread. The socket works ok
(accepts connections and blocks again etc). The problem is that when I try
to close the socket,
shutdown blocks and the socket doesnt close.
(in the same application if I use winsocket 1 - accept -, instead of
winsocket 2 the socket closes OK).

The source is something like this:

if(m_hSocket!=INVALID_SOCKET)
 {
  shutdown(m_hSocket,SD_RECEIVE);
  closesocket(m_hSocket);
 }

The other thread is blocked in WSAAccept()

Any ideas ?
Thanx in advance

PS:
For a simple TCP/IP application would I profit by using winsocket 2 instead
of 1 (I mean in performance)

 
 
 

Shutdown Listening socket (win socket 2 - vs 1)

Post by Alun Jon » Tue, 03 Dec 2002 22:32:47




Quote:>In my server - side TCP /IP application , I create a listening blocking
>socket.
>The WSAAccept is called from a different thread. The socket works ok
>(accepts connections and blocks again etc). The problem is that when I try
>to close the socket,
>shutdown blocks and the socket doesnt close.

It's not documented what, if anything, shutdown() will do to a listening
socket.  Just close the listening socket.

Alun.
~~~~

[Please don't email posters, if a Usenet response is appropriate.]
--
Texas Imperial Software   | Try WFTPD, the Windows FTP Server. Find us at

Cedar Park TX 78613-1419  | VISA/MC accepted.  NT-based sites, be sure to
Fax/Voice +1(512)258-9858 | read details of WFTPD Pro for XP/2000/NT.

 
 
 

Shutdown Listening socket (win socket 2 - vs 1)

Post by Jiannis » Tue, 03 Dec 2002 22:52:58


I 've already tried that and it blocks too (closesocket)
(And as I mentioned it works fine when I use winsock 1)



> >In my server - side TCP /IP application , I create a listening blocking
> >socket.
> >The WSAAccept is called from a different thread. The socket works ok
> >(accepts connections and blocks again etc). The problem is that when I
try
> >to close the socket,
> >shutdown blocks and the socket doesnt close.

> It's not documented what, if anything, shutdown() will do to a listening
> socket.  Just close the listening socket.

> Alun.
> ~~~~

> [Please don't email posters, if a Usenet response is appropriate.]
> --
> Texas Imperial Software   | Try WFTPD, the Windows FTP Server. Find us at

> Cedar Park TX 78613-1419  | VISA/MC accepted.  NT-based sites, be sure to
> Fax/Voice +1(512)258-9858 | read details of WFTPD Pro for XP/2000/NT.

 
 
 

Shutdown Listening socket (win socket 2 - vs 1)

Post by arkady » Tue, 03 Dec 2002 23:35:53


It have to work when you close the listening socket , closesocket simply
kill accept()/WSAAccept(). It have to return with INVALID_SOCKET when
listen socket killed.
Arkady


> I 've already tried that and it blocks too (closesocket)
> (And as I mentioned it works fine when I use winsock 1)






> > >In my server - side TCP /IP application , I create a listening blocking
> > >socket.
> > >The WSAAccept is called from a different thread. The socket works ok
> > >(accepts connections and blocks again etc). The problem is that when I
> try
> > >to close the socket,
> > >shutdown blocks and the socket doesnt close.

> > It's not documented what, if anything, shutdown() will do to a listening
> > socket.  Just close the listening socket.

> > Alun.
> > ~~~~

> > [Please don't email posters, if a Usenet response is appropriate.]
> > --
> > Texas Imperial Software   | Try WFTPD, the Windows FTP Server. Find us
at

> > Cedar Park TX 78613-1419  | VISA/MC accepted.  NT-based sites, be sure
to
> > Fax/Voice +1(512)258-9858 | read details of WFTPD Pro for XP/2000/NT.

 
 
 

Shutdown Listening socket (win socket 2 - vs 1)

Post by arkady » Tue, 03 Dec 2002 23:41:20


OTOH , If you think that accept() is of winsock1 and WSAAccept() is of
winsock2 it's not true , because both exists in Winsock1 and 2 . BTW If you
are in
NT kernel OS you always call winsock2 even you ask for 1 in WSAStartup.
In W9x it's not true. You have to call explicitly Winsock you need.
Arkady


> It have to work when you close the listening socket , closesocket simply
> kill accept()/WSAAccept(). It have to return with INVALID_SOCKET when
> listen socket killed.
> Arkady



> > I 've already tried that and it blocks too (closesocket)
> > (And as I mentioned it works fine when I use winsock 1)





> > > >In my server - side TCP /IP application , I create a listening
blocking
> > > >socket.
> > > >The WSAAccept is called from a different thread. The socket works ok
> > > >(accepts connections and blocks again etc). The problem is that when
I
> > try
> > > >to close the socket,
> > > >shutdown blocks and the socket doesnt close.

> > > It's not documented what, if anything, shutdown() will do to a
listening
> > > socket.  Just close the listening socket.

> > > Alun.
> > > ~~~~

> > > [Please don't email posters, if a Usenet response is appropriate.]
> > > --
> > > Texas Imperial Software   | Try WFTPD, the Windows FTP Server. Find us
> at
> > > 1602 Harvest Moon Place   | http://www.wftpd.com or email


- Show quoted text -

Quote:> > > Cedar Park TX 78613-1419  | VISA/MC accepted.  NT-based sites, be sure
> to
> > > Fax/Voice +1(512)258-9858 | read details of WFTPD Pro for XP/2000/NT.