🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Tryt to bind TClientSocket to specific LocalPort

#2825
From: Orlando Lopez
Date: Sat, 21 Jan 2006 02:45
31 lines
1696 bytes
Hi to all,

I'm trying to bind specific port (3033) to my TClientSocket.
I'm trying to do this (Thanks gambit, this code was original in delphi),
but I;m getting some errors, why?


void __fastcall TForm1::ClientSocket1Lookup(TObject *Sender,
      TCustomWinSocket *Socket)
{
    TSockAddrIn *Addr;
    int Err;

    memset(Addr, 0, sizeof(Addr));
    Addr->sin_family = PF_INET;
//here : [C++ Error] E2034 Cannot convert 'unsigned long' to 'in_addr'
    Addr->sin_addr = INADDR_ANY;
    Addr->sin_port = htons(3033);

    if (bind(Socket->SocketHandle, Addr, sizeof(Addr)) != 0)
    {
        Err = WSAGetLastError;
        if (Err != WSAEWOULDBLOCK)
        {
            ShowMessage("Some Error ocurred, check");
        }
    }
}

Tnanks in advance
Technical Details
Message-ID: <43d1ae4b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,98a68f0c9b203d3,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Orlando Lopez" <hlopezrd@hotmail.com>
Sender: "Orlando Lopez" <hlopezrd@hotmail.com>
Reply-To: "Orlando Lopez" <hlopezrd@hotmail.com>
Subject: Tryt to bind TClientSocket to specific LocalPort
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 200.88.202.77     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <43d1ae4b$1@newsgroups.borland.com>
Date: 20 Jan 2006 19:45:15 -0700
X-Trace: newsgroups.borland.com 1137815115 207.105.83.66 (20 Jan 2006 19:45:15 -0700)
Lines: 31
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail