Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem with tcp/ip communication between client and server

773613May 18 2010 — edited May 18 2010
my requirement is:
i am using utl_tcp package for tcp/ip communication between client(my client application based on c#) and server(plsql code for server).

when i am sending data to client, then client receives that data successfully but when client sends back some data to server, my code does not receive client's requested data.

1. use this package
Code: [Select all] [Show/ hide]

CREATE OR REPLACE PACKAGE BODY TESTING.test_tcp_ip_conn
IS
g_l_con UTL_TCP.connection;

PROCEDURE send_message (p_message IN VARCHAR2)
IS
BEGIN
g_l_con :=
UTL_TCP.open_connection (remote_host => '192.210.1.20',
remote_port => 11500
);
v_ret_val := UTL_TCP.write_line (g_l_con, p_message);
cyms_trace.createlog_into_directory
('TESTING.TEST_TCP_IP_CONN.SEND_MESSAGE',
TO_CHAR (v_ret_val)
);

UTL_TCP.close_connection (g_l_con);
UTL_TCP.close_all_connections;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('error = ' || SQLERRM);
UTL_TCP.close_all_connections;
RETURN;
END;

PROCEDURE receive_message
IS
v_ret_val NUMBER;
v_data VARCHAR2 (255);
v_num NUMBER;
len PLS_INTEGER;
--v_count BOOLEAN := FALSE;
BEGIN
UTL_TCP.close_all_connections;
g_l_con :=
UTL_TCP.open_connection (remote_host => '132.186.97.169',
remote_port => 1521
);

BEGIN
WHILE TRUE
LOOP
dbms_output.PUT_LINE(utl_tcp.GET_LINE(g_l_con,true));
IF UTL_TCP.available (g_l_con) > 0
THEN
len := UTL_TCP.read_text (g_l_con, v_data, 256);
DBMS_OUTPUT.put_line (len);
cyms_trace.createlog_into_directory
('TESTING.TEST_TCP_IP_CONN.RECEIVE_MESSAGE',
TO_CHAR (len)
);
--v_ret_val := UTL_TCP.read_line (g_con, v_data, FALSE);
DBMS_OUTPUT.put_line (v_data);
cyms_trace.createlog_into_directory
('TESTING.TEST_TCP_IP_CONN.RECEIVE_MESSAGE',
v_data
);
END IF;
END LOOP;
EXCEPTION
WHEN UTL_TCP.end_of_input
THEN
NULL;
END;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('error = ' || SQLERRM);
cyms_trace.createlog_into_directory
('TESTING.TEST_TCP_IP_CONN.RECEIVE_MESSAGE',
SQLERRM
);
UTL_TCP.close_all_connections;
RETURN;
END;
END;
/


2. call send_message procedure from this procedure.
Code: [Select all] [Show/ hide]

CREATE OR REPLACE PROCEDURE testing.sendtohmi
AS
v_mesg VARCHAR2 (200) := NULL;
BEGIN
v_mesg := '11022 hello ?? \n';
testing.test_tcp_ip_conn.send_message (v_mesg);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('error = ' || SQLERRM);
cyms_trace.createlog_into_directory ('TESTING.SENDTOHMI', SQLERRM);
RETURN;
END;


3. call receive_message procedure from the job.

please give me positive feed back, so that i can use this package successfully.


regard's
manoj olak
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2010
Added on May 18 2010
2 comments
808 views