Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PostgreSQL pgsocket: Extension for Simple TCP/IP Socket Client

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Background

PostgreSQL plug-in, which produces byte flow to external tpc/ip socket services.

Pgsocket is an extension for PostgreSQL server to send bytes to remote TCP/IP socket server.

For the first version only single function provided for one way data send in bytearray.

This extension is compiled in Linux against PostgreSQL version 10.

Download source code from https://github.com/AbdulYadi/pgsocket. Build in Linux as usual:

$USE_PGXS=1 make clean $USE_PGXS=1 make $USE_PGXS=1 make install

On successful compilation, install this extension in PostgreSQL environment

$create extension pgsocket

Let us send bytes to-for example- host with IP address nnn.nnn.nnn.nnn, port 9090, send time out 30 seconds, messages' Hello'

$select pgsocketsend ('nnn.nnn.nnn.nnn', 9090, 30, (E'\\ x'| | encode ('Hello',' hex')):: bytea)

Or using address host name instead of IP address

$select pgsocketsend ('thesocketserver', 9090, 30, (E'\\ x'| | encode ('Hello',' hex')):: bytea)

Now, sending text from a table to remote TCP/IP socket server is easy. Assuming there is a table words:

Id txt-1 Life is easy 2 with PostgreSQL

Just do:

$select pgsocketsend ('thesocketserver', 9090, 30, (E'\\ x'| | encode (t.txt, 'hex')):: bytea) from words t WHERE t.id = 1; reference

Https://abdulyadi.wordpress.com/2018/09/11/pgsocket-extension-for-simple-socket-client/

Https://github.com/AbdulYadi/pgsocket

Https://abdulyadi.wordpress.com/2015/11/14/extension-for-qr-code-bitmap/

Https://abdulyadi.wordpress.com/2012/03/03/consume-soap-web-service-from-postgresql-user-defined-function-in-c/

Original address: https://github.com/digoal/blog/blob/master/201809/20180913_03.md

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report