Send commands to Arduino via Socket-Connection


i have an arduino running to which i send commands via apache+php.
Now i think about to implement this directly in openhab to get rid of apache+php.
can anyone point me to the right binding/way?

This is the function where the magic of sending happens:

	function arduino_send($ip, $port, $command)
		$res = fsockopen($ip, $port);
		stream_set_timeout($res, 10, 0);
			fwrite($res, $command);
			$ret = fgets($res);
			if ($ret == "")
				$ret = "ERR";
			return $ret;
			return "N/A#";

This is the code i use in an other script, that i call with sendHttpGetRequest:

$response = arduino_send($arduino_ip, $arduino_port, "S.1.0");

The Arduino sends a longer string back as status.
After update str_dummy_refresher_for_rules with this response, i split and substring this response-code.
after this i set a lot of items via if to corresponding states.

    var lkrFull		= str_dummy_refresher_for_rules.state.toString()  // e.g. R2#
    var lkrFullLR	= lkrFull.split("#")
    var lkrStateL	= lkrFullLR.get(0)
    var lkrStateR	= lkrFullLR.get(1)
    var lkrState_00	= lkrStateR.substring( 0,  1)
    var lkrState_01	= lkrStateR.substring( 2,  3)
    var lkrState_02	= lkrStateR.substring( 4,  5)
    var lkrState_03	= lkrStateR.substring( 6,  7)
    var lkrState_04	= lkrStateR.substring( 8,  9)
    var lkrState_05	= lkrStateR.substring(10, 11)
    var lkrState_06	= lkrStateR.substring(12, 13)
    var lkrState_07	= lkrStateR.substring(14, 15)
    var lkrState_08	= lkrStateR.substring(16, 17)
    var lkrState_09	= lkrStateR.substring(18, 19)
    var lkrState_10	= lkrStateR.substring(20, 21)
    var lkrState_11	= lkrStateR.substring(22, 23)
    var lkrState_12	= lkrStateR.substring(24, 25)
    var lkrState_13	= lkrStateR.substring(26, 27)
    var lkrState_14	= lkrStateR.substring(28, 29)
    var lkrState_15	= lkrStateR.substring(30, 31)

thanks for reading

It is an IP-Connection via Ethernet. I do not want to change the firmware on arduino. I only want to send commands to it using a direct tcp/ip connection - i think.

I am using:

EthernetClient client;

for getting data.