problem with tcp/ip communication between client and server [message #456461] |
Tue, 18 May 2010 01:53  |
manojolak
Messages: 4 Registered: May 2010 Location: kolkata
|
Junior Member |
 
|
|
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.
manoj olak
[Updated on: Tue, 18 May 2010 02:01] by Moderator Report message to a moderator
|
|
|
|
|
problem with tcp/ip communication between client and server [message #456494 is a reply to message #456461] |
Tue, 18 May 2010 03:06   |
manojolak
Messages: 4 Registered: May 2010 Location: kolkata
|
Junior Member |
 
|
|
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
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.
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.
regard's
manoj olak
CM: added [code] tags - please do so yourself next time - see the orafaq forum guide if you're not sure how.
[Updated on: Tue, 18 May 2010 03:20] by Moderator Report message to a moderator
|
|
|
|