🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Restricting Local IP in TServerSocket

#5561
From: Cagatay Undeger
Date: Thu, 05 Aug 2004 22:20
52 lines
2402 bytes
Hi,

I tried what you proposed but did not work.
I created a class as follows:

class TMyServerSocket : public TServerSocket
{
public:
        __fastcall virtual TMyServerSocket (Classes::TComponent* AOwner)
                : TServerSocket (AOwner)
        {
        }
        void SetLocalAddress ( AnsiString address )
        {
                Address = address;
        };
};

Then I connected as follows:

TServerSocket * ServerSocket = new TMyServerSocket(NULL);
((TMyServerSocket*)ServerSocket)->SetLocalAddress ( ip );
ServerSocket->Port    = port;
ServerSocket->Active = true;

But when I print the Socket->LocalAddress property,
it writes 0.0.0.0 and still works with multiple IP.

Cagatay

"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:4112a709$1@newsgroups.borland.com...
>
> "Cagatay Undeger" <cagatay@interaktif.gen.tr> wrote in message
> news:41129f35$1@newsgroups.borland.com...
>
> > I would like to select only one of the local addresses for
> > listening on a port when more than one ethernet card and
> > ip exist on a single machine. Is it possible to do that using
> > TServerSocket?
>
> Yes.  Derive a new class from TServerSocket, then you will have access to
> its protected Address property.  That value is used to bind the server to
a
> particular IP.  Since it is not publically accessible, its value is
usually
> empty, thus the server normally binds to all available addresses.
>
>
> Gambit
>
>
Technical Details
Message-ID: <4112b291@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <41129f35$1@newsgroups.borland.com> <4112a709$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,275bb228249b0ef9
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Cagatay Undeger" <cagatay@interaktif.gen.tr>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41129f35$1@newsgroups.borland.com> <4112a709$1@newsgroups.borland.com>
Subject: Re: Restricting Local IP in TServerSocket
Date: Fri, 6 Aug 2004 01:20:07 +0300
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 195.174.150.26
Message-ID: <4112b291@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1091744401 195.174.150.26 (5 Aug 2004 15:20:01 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail