pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: eem21@cam.ac.uk
To: tgl@sss.pgh.pa.us
Cc: pgsql-interfaces@postgresql.org
Subject: Re: [INTERFACES] Asynchronous connect using libpq
Date: Sun, 18 Jul 1999 17:02:29 +0100 (BST)
Message-ID: <E115tHg-00057Q-00@red.csi.cam.ac.uk> (raw)
In-Reply-To: <7232.932312914@sss.pgh.pa.us>

On 18 Jul, Tom Lane wrote:
> eem21@cam.ac.uk writes:
>> I realised that some time after I sent my first message, and have been
>> thinking about it since.  The delay for gethostbyname is not
>> acceptable, and we are going to have to get around that problem
>> elsewhere in the application anyway.  Therefore, I was thinking that I
>> could arrange to pass an IP address into libpq.
> 
> A dotted-decimal address, you mean?  Yeah, that sounds like it should
> work.

Or a struct in_addr *.  I'll have to see how IPv6 addresses are being
shoehorned into the socket schemes.  Perhaps we could support them too.

>> With regards to the connect() problem, I was hoping that by setting the
>> socket to non-blocking mode before connecting (exactly as it is
>> currently done after the connect call) I could solve that problem.
> 
> By golly, there is something about non-blocking connect in the man page:
> 
>      If the socket is of type SOCK_STREAM, connect() attempts to contact
>      the remote host in order to make a connection between the remote
>      socket (peer) and the local socket specified by s.  The call normally
>      blocks until the connection completes.  If non-blocking mode has been
>      enabled using the O_NONBLOCK or O_NDELAY fcntl() flags or the FIOSNBIO
>      ioctl() request and the connection cannot be completed immediately,
>      connect() returns an error as described below.  In these cases,
>      select() can be used on this socket to determine when the connection
>      has completed by selecting it for writing.
> 
> Maybe you can make this work after all, with the limitation that the
> user must supply a dotted-decimal IP address (or use a Unix-domain
> connection) if he doesn't want to risk DNS lookup delays.
> 
> Good luck!

Thanks!

Ewan.




view thread (5+ messages)

Message-ID: <E115tHg-00057Q-00@red.csi.cam.ac.uk>
Permalink:  ../E115tHg-00057Q-00@red.csi.cam.ac.uk/
Also on:    postgresql.org/message-id/E115tHg-00057Q-00@red.csi.cam.ac.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: eem21@cam.ac.uk, tgl@sss.pgh.pa.us
  Subject: Re: [INTERFACES] Asynchronous connect using libpq
  In-Reply-To: <E115tHg-00057Q-00@red.csi.cam.ac.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox