插座连接 [英] socket connection
本文介绍了插座连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过套接字通过oracle 11g数据库将字符串发送到外部人机界面 我认为必须首先将字符或字符串转换为十六进制,然后在字符串末尾添加校验和(以验证要发送的字符串)
I would like to send a string via a socket to an external display unit via the oracle 11g database I gather that the character or string first has to be converted to hex and at the end of the string a checksum must be addead (to validate the string to be sent)
谁能告诉我如何打开套接字连接并发送字符串?
Can anyone tell me how a socket connection can be opened and a string can be sent?
谢谢
推荐答案
DECLARE
bt_conn UTL_TCP.connection;
retval BINARY_INTEGER;
l_sequence VARCHAR2 (50) := '@0100010303000118000201001401000201'; --string to be sent
BEGIN
bt_conn :=
UTL_TCP.open_connection (remote_host => '127.0.0.1', --IP of socket to be opened
remote_port => 26665, -- port number of socket
tx_timeout => 15);
DBMS_LOCK.SLEEP(1); -- this is to ensure a slight pause once opening the connection before --sending the string
retval := UTL_TCP.write_line (bt_conn, l_sequence);
UTL_TCP.flush (bt_conn);
UTL_TCP.close_connection (bt_conn);
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (-20101, SQLERRM);
UTL_TCP.close_connection (bt_conn);
end;
这篇关于插座连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文