PostgreSQL pgsocket: Extension for Simple TCP/IP Socket Client

发布时间:2020-08-11 11:33:21 作者:digoal
来源:ITPUB博客 阅读:193

背景

PostgreSQL 插件,向外部tpc/ip socket服务发生字节流。

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;

参考

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/

原文地址:https://github.com/digoal/blog/blob/master/201809/20180913_03.md

推荐阅读:
  1. CSS-T | Mysql Client 任意文件读取攻击链拓展
  2. php实现自动关闭订单的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

client extension simple

上一篇:子窗体与父窗体的通讯

下一篇:phpcms发布文章出错的解决方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》