PostgreSQLpgsocket:ExtensionforSimpleTCP/IPSocketClient

背景

PostgreSQL 插件,向外部tpc/ip socket服務(wù)發(fā)生字節(jié)流。

創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的古冶網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

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

網(wǎng)站名稱:PostgreSQLpgsocket:ExtensionforSimpleTCP/IPSocketClient
文章源于:http://bm7419.com/article4/pscsie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號外貿(mào)建站、定制網(wǎng)站、網(wǎng)站內(nèi)鏈、手機網(wǎng)站建設(shè)、App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)