send 'byteArray' through socket

Asked by Silverallis

Hi Greats...

Once again I have a question and am sure will get a quick answer.

I am trying to communicate to another device using socket.
Here is my code :

import socket

data = bytearray(b"hello world")
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("192.168.1.2", 5000))
client_socket.send(data)
client_socket.close()

The above code works fine on python, but when I tried to run the same in Sikuli. It displays 'bytearray' not defined error. Is there any alternative to send the info through socket.
The server requires ASCII info. I tried convert it into ascii and send but I wasn't able to.

Thanks for your valuable time and help.

Regards,
Silverallis

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Silverallis
Solved:
Last query:
Last reply:
Revision history for this message
Silverallis (silverallis) said :
#1

Resolved..using ASCII conversion.

Revision history for this message
Fyodor (simexie) said :
#2

Hi,

Could you provide a url to manual about using sockets in Sikuli scripts.
I've tried here http://www.jython.org/jythonbook/en/1.0/search.html?q=socket&check_keywords=yes&area=default
and here http://doc.sikuli.org/search.html?q=socket&check_keywords=yes&area=default
There are not any search results.

Thanks in advance.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

googling "jython socket" returns as first entry ;-)

http://www.jython.org/docs/library/socket.html

Revision history for this message
Fyodor (simexie) said :
#4

 Looks like this is secret passage :) Thank you.