Re: connection failure: timeout
- From: "John" <johnli1995@xxxxxxxxxxx>
- Date: Thu, 27 Oct 2005 20:16:26 GMT
Thanks much for everyone's reply.
I tried to bind "0.0.0.0" it works. So should not use loopback interface
when binding in client socket.
Cheers!
-John
"Alun Jones" <alun@xxxxxxxxxxxxx> wrote in message
news:P7qdnY0YwPqorvzenZ2dnUVZ_sidnZ2d@xxxxxxxxxxxxxx
> Phil Frisbie, Jr. wrote:
>> You almost never need to bind a client TCP socket to a specific port.
>>
>> In fact the ONLY example I have ever come across was a UNIX service that
>> required you to bind to a privileged port below 1024 to prove you were
>> 'root' on the client machine.
>
> In an FTP server, you need to bind to port 20 before connecting to the FTP
> client's listening port specified by the PORT command. Note that in this
> case, the FTP server acts as a TCP client, and the FTP client acts as a
> TCP server.
>
> But yes, in general, calling bind() before calling connect() is wrong. In
> this case, the address chosen is exactly the cause of the OP's problem -
> the code binds to 127.0.0.1:0 (in other words, to the localhost
> loopback-only address, and to whatever random port number Winsock assigns)
> before connecting. Binding to a loopback-only address is preventing the
> connect() from working to any address outside of the loopback-only range.
>
> The OP should instead bind to 0.0.0.0:0, but then, that's exactly the
> behaviour that occurs if you don't call bind() before calling connect().
> So, the OP should follow the advice of not calling bind() before calling
> connect(). If he must call bind(), he should leave the IP address as
> INADDR_ANY (0.0.0.0), not INADDR_LOOPBACK (127.0.0.1)
>
> Alun.
> ~~~~
> [Please don't email posters, if a Usenet response is appropriate.]
> --
> Texas Imperial Software | Find us at http://www.wftpd.com or email
> 23921 57th Ave SE | alun@xxxxxxxxxx
> Washington WA 98072-8661 | WFTPD, WFTPD Pro are Windows FTP servers.
> Fax/Voice +1(425)807-1787 | Try our NEW client software, WFTPD Explorer.
>
>
.
- Follow-Ups:
- Re: connection failure: timeout
- From: Alun Jones
- Re: connection failure: timeout
- From: Eugene Gershnik
- Re: connection failure: timeout
- References:
- connection failure: timeout
- From: John
- Re: connection failure: timeout
- From: Eugene Gershnik
- Re: connection failure: timeout
- From: John
- Re: connection failure: timeout
- From: Arkady Frenkel
- Re: connection failure: timeout
- From: John
- Re: connection failure: timeout
- From: Phil Frisbie, Jr.
- Re: connection failure: timeout
- From: Alun Jones
- connection failure: timeout
- Prev by Date: Re: connection failure: timeout
- Next by Date: Re: connection failure: timeout
- Previous by thread: Re: connection failure: timeout
- Next by thread: Re: connection failure: timeout
- Index(es):
Relevant Pages
|