← Back to team overview

sikuli-driver team mailing list archive

[Question #434373]: Socket Communication Error

 

New question #434373 on Sikuli:
https://answers.launchpad.net/sikuli/+question/434373

1.1.994(2015-10-22_11:34nightly)/Windows6.1/Java7(32)1.7.0_79-b15

I have a problem of socket communications with sikuli.
Could you please help me?

I wrote the following ruby script as server.

--< ShareData.rb >----------------------------------------------
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'socket'

# server settings
host_name = "127.0.0.1"
host_port = 5001

serv = TCPServer.open(host_name, host_port)

#-------- request from a client
km_data = {} # shared data
begin
	loop do
		Thread.start(serv.accept) do |sock|
			puts "client accept"
			while msg = sock.gets.chomp
				data = msg.split(',', -1)
				req_type = data[0]
				
				case req_type
				#-------- set: setter of data, format: "set", key, data
				when "set"
					km_data[ data[1] ] = data[2]
					puts km_data
				#-------- get: getter of data, format: "get", key
				when "get"
					#-------- send the data
					if km_data.has_key?(data[1])
						sock.puts(km_data[ data[1] ],"\r\n")
					else
						sock.puts("\r\n")
					end
				else
					puts "req_type = #{req_type}"
				end
			end
			sock.close
		end
	end
rescue
	puts "ERR:TCPServer close."
	sleep(10)
end

serv.close

----------------------------------------------------------------

And I wrote the following sikuli scripts as client.

--< sample.py >-------------------------------------------------
# -*- coding: utf-8
import socket
from contextlib import closing

host = "127.0.0.1"    # host name
port = 5001           # port number
bufsize = 4096        # buffer size

def shareDataSet(key, data):
    print("shareDataSet(): key=%s data=%s" % (key, data))

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((host, port))

    req = "set" + "," + key + "," + str(data)
    sock.send(req)
    print(">>>SET : %s" % (data))
    sock.close()

key = "key-sample"

# set data
data_set = "5678"
shareDataSet(key, data_set)

----------------------------------------------------------------

I executed them in the following steps:

1. Run the server with the command.
    % ruby ShareData.rb
2. Startup the client(sikuli) with the runsikulix.cmd.
3. Run the sample.py on the sikuli.
    ---- This works correctly.
4. Run the sample.py on the sikuli again, without quitting the sikuli.
    ---- Java outputs an exception.

The exception is happened at the line 359 of sikulix.jar\Lib\_socket.py,
And this is not happened at the version 1.0.1 of the sikuli.

If you have an advice or a prevention, and give it to me,
it will be my great help.

Thanks.



-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.