🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4629

Re: Blocking Socket Help

#4629
From: Remy Lebeau (TeamB)
Date: Fri, 07 Jan 2005 17:45
38 lines
2424 bytes
"mike" <mfbrowne@earthlink.net> wrote in message
news:41deb491$1@newsgroups.borland.com...

> Now my problem is this: If I try and disconnect the socket from the
> server side I can't get the socket to close because the clients try and
> connect causing the server socket to start another thread.

Only if the server is still listening for connections.  If you are closing
the server itself, it will stop listening, thus no more clients can connect.

> So I put in a flag to tell the server socket to not create the thread, but
> this does not help as the server socket still creates a connection.

If you do not want clients to connect, but you do not want to close the
server itself, then use the OnAccept event to close new connections
immediately.

> So I tried to close the ServerSocket itself and then close the active
> threads but when I do this the ServerSocket reports there are no
> active connections.

You don't need to close the threads yourself.  The ServerSocket does that
automatically.

> Anyway I am totally confused on how to properly close the Server Socket

Just close it.  You don't need to do anything else.  Everything is handled
for you.

> Now the thread does get closed but by the time I have tried to
> close all the sockets more threads more have started.

It does not matter.  They will still get closed anyway.  Do not close them
yourself at all.


Gambit
Technical Details
Message-ID: <41deca4a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41deb491$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b1c5fb84bd800066
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41deb491$1@newsgroups.borland.com>
Subject: Re: Blocking Socket Help
Date: Fri, 7 Jan 2005 09:45:13 -0800
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <41deca4a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1105119818 68.69.17.41 (7 Jan 2005 09:43:38 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail