ANNOUNCEMENT:

jLina is Released! Download the binaries from SourceForge (v1.1)

Home | Features | FAQ | Project members | Examples | Links

Server configuration examples

1. Full jlina.conf example:
# Define the operations file in which all service operations are defined
jlina.opfile = operations.txt

# [optional] Define maximum threads (connection sessions) allowed, -1 for no limit (default -1).
jlina.maxthreads = 200

# [optional] Define IP which jLina will be listening to (default 127.0.0.1)
jlina.ip = 127.0.0.1

# [optional] Define port which jLina will be listening to (default 2306)
jlina.port = 2306

# [optional] Define logging file (by default if this parameter is not set, logging is disabled)
jlina.logfile = jlina.log

# [optional] Define session life per connection thread (default 60 seconds)
jlina.sessionlife = 60000

# [optional] Define if delimiter is allowed or disallowed in client requests, 0 for disallow, 1 for allow (default 0)
jlina.delimiter = 0

# Define the source name for the ODBC database to use
odbc.sourcename = jLina
2. Operations file example:
# This operation defines a basic select. Since the operation has one question mark, it is defined to have only one parameter as input
# The service name is BasicSelect
BasicSelect SELECT * FROM user_names where user_name = ?

# This operation defines a basic select. Since the operation has no question marks at all, it is defined to have no input
# The service name is HelloWorld
HelloWorld SELECT 'Hello World'

# This operation defines a call to an application. Since the operation has one question mark, the input parameter will be passed
# as a command line parameter to the actual application
# The service name is !Test
!Test C:\Users\Boro\Desktop\Test.exe ?

Client examples

1. Python example:
import zlib, socket, sys

def InvokeService(MESSAGE):

	HOST = 'localhost'
	PORT = 2306

	compressed_message = zlib.compress(MESSAGE.encode())
	#print("Sending len: ", len(compressed_message), " / ", len(MESSAGE))

	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.connect((HOST, PORT))

	s.send(compressed_message)

	data = s.recv(1024)
	s.close()

	if (len(data) == 1):
		if (data == b'0'): data = 'JLINAERROR_SERVICE_NOT_FOUND'
		elif (data == b'1'): data = 'JLINAERROR_INVALID_PARAMETERS'
		elif (data == b'2'): data = 'JLINAERROR_NIL_RESULT'
		elif (data == b'3'): data = 'JLINAERROR_NODB_CONNECTION'
		elif (data == b'4'): data = 'JLINAERROR_COMPRESS_FAILED'
		elif (data == b'5'): data = 'JLINAERROR_DECOMPRESS_FAILED'
		elif (data == b'6'): data = 'JLINAERROR_PROCESS_FAILED'
		return data
	else:
		zlibd = zlib.decompress(data).decode()
		#print("Received len: ", len(data), " / ", len(zlibd))
		return zlibd

# Now calling a service is as easy as
x = InvokeService("getjLinaVersion")
# OR x = InvokeService("BasicSelect Boro")
print(x)
2. Java example:
//...
3. PHP example:
<?php
error_reporting(E_ALL);

function InvokeService($MESSAGE) {

	$HOST = 'localhost';
	$PORT = 2306;

	$compressed_message = gzcompress($MESSAGE, 9);
	//echo "Sending len " . strlen($compressed_message) . " / " . strlen($MESSAGE) . "\n";

	$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	if ($s === false) return -1;
	socket_connect($s, gethostbyname($HOST), $PORT);

	socket_write($s, $compressed_message, strlen($compressed_message));

	$data = socket_read($s, 1024);
	socket_close($s);

	if (strlen($data) == 1) {
		if ($data == '0') $data = 'JLINAERROR_SERVICE_NOT_FOUND';
		else if ($data == '1') $data = 'JLINAERROR_INVALID_PARAMETERS';
		else if ($data == '2') $data = 'JLINAERROR_NIL_RESULT';
		else if ($data == '3') $data = 'JLINAERROR_NODB_CONNECTION';
		else if ($data == '4') $data = 'JLINAERROR_COMPRESS_FAILED';
		else if ($data == '5') $data = 'JLINAERROR_DECOMPRESS_FAILED';
		else if ($data == '6') $data = 'JLINAERROR_PROCESS_FAILED';
		return $data;
	} else {
		$zlibd = gzuncompress($data);
		//echo "Received len: " . strlen($data) . " / " . strlen($zlibd) . "\n";
		return $zlibd;
	}
}
// Now calling a service is as easy as
$x = InvokeService("getjLinaVersion");
// OR $x = InvokeService("BasicSelect Boro");
echo $x;
?>
4. C/C++ example:
//...
5. C# example:
//...
Home | Features | FAQ | Project members | Examples | Links