Startup messages for socket protocol

From: Guillaume Yziquel <guillaume(dot)yziquel(at)citycable(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Startup messages for socket protocol
Date: 2011-03-17 14:20:41
Message-ID: 20110317142041.GX22969@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi.

I've been trying to get a connection working to a PostgreSQL server
through the socket-level protocol. I've therefore been looking at
fe-connect.c and fe-protocol3.c in the src/interfaces/libpq folder.

Reading those sources, I understood, that the startup message should
begin with a request from the client with the protocol number.

In fe-protocol3.c, build_startup_message():

/* Protocol version comes first. */
if (packet)
{
ProtocolVersion pv = htonl(conn->pversion);

memcpy(packet + packet_len, &pv, sizeof(ProtocolVersion));
}
packet_len += sizeof(ProtocolVersion);

However, when I try to send this as the first thing, I get disconnected
by the server. Reading what the psql program does, I first get an 8 byte
message containing this:

\000\000\000\008\004\210\022/

This seems to work, but I'm at a loss pinpointing in the libpq source
code where that would fit in the protocol.

Enlightenment would be very welcome.

--
Guillaume Yziquel

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gauthier, Dave 2011-03-17 14:48:37 Getting users/privs for tables.
Previous Message Alexander Farber 2011-03-17 13:46:05 Re: A join of 2 tables with sum(column) > 30