🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Changing Ports in IdTCP?

#4024
From: qyte
Date: Wed, 27 Apr 2005 10:41
35 lines
2143 bytes
i use the following function in order to change the port
for the sockets.

bool TForm1::changeport()
{
         if(Client->Port==port) return true;
         if(connected)
         {
                 try{
                         if(IsServer)
                                 TServer->Bindings->Items[0]->Port=port;
                         else
                                 Client->Port=port;
                         }catch(Exception &e)
                         {
                                 ShowMessage(e.Message);
                         }
                 return false;
         }
         TServer->Bindings->Clear();
         TIdSocketHandle *SocketHandle;
         SocketHandle=TServer->Bindings->Add();
         SocketHandle->Port=port;
         SocketHandle->IP="0.0.0.0";
         Client->Port=port;
         Client_m->Port=port;
         Client_s1->Port=port;
         Client_s2->Port=port;
         return true;
}

what i want is to throw an exception if the port
is already bound (for the server) or if the socket is
active generrally. is works well with TSS/TCS but
with indy (9) sockets no exception is thrown.
Technical Details
Message-ID: <426f6c5a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!news.net.uni-c.dk!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ec5a26943f4067ee,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 27 Apr 2005 13:41:28 +0300
From: qyte <gyte@vivodinet.gr>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Changing Ports in IdTCP?
Content-Type: text/plain; charset=ISO-8859-7; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 62.74.141.196
Message-ID: <426f6c5a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1114598490 62.74.141.196 (27 Apr 2005 03:41:30 -0700)
Lines: 35
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!news.net.uni-c.dk!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail