@Geoffry Akien--I'm not able to duplicate your 2nd error (the one with jtcp_version01), so I'm not sure what to say about that. Your 1st error is really mysterious: a failed jtcp_request_connection() on my machine results in a "connect timed out" error, but the message you get says "Read timed out". I don't know the inner workings of Java well enough to understand why it should be attempting a read operation when you are requesting a connection, so I'm afraid I'm not going to be able to offer you any help here.
I want to use port 502 (I can't change this), but your code formally does not allow the user of ports <1025. I have a device which works just fine using tcpip in the instrument toolbox, but I was hoping to get rid of the dependency by using your code.
Naively changing this limit and using 2012bx64 on W7E I get the following:
>> j = jtcp('REQUEST', '10.10.10.4', 502)
Error using jtcp>jtcp_request_connection (line 293)
Java exception occurred:
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
Error in jtcp (line 230)
jTcpObj = jtcp_request_connection(host,port,timeout,serialize);
...but using the same approach with jtcp_version01 seems to work initially:
>> j = jtcp_version01('REQUEST', '10.10.10.4', 502)
socket: [1x1 java.net.Socket]
inputStream: [1x1 java.net.SocketInputStream]
dataInputStream: [1x1 java.io.DataInputStream]
outputStream: [1x1 java.net.SocketOutputStream]
dataOutputStream: [0 java.io.DataOutputStream]
...but then sending something gives this error:
jtcp_version01('WRITE', j, int8(c))
Error using jtcp_version01>jtcp_write (line 384)
Java exception occurred:
java.net.SocketException: Software caused connection abort: socket
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.DataOutputStream.write(Unknown Source)
Error in jtcp_version01 (line 258)
...although closing the connection seems to work without complaint.
Zack, Psychtoolbox already contains a TCP/IP UDP interface, which i use to control neurophysiology amplifiers (has a client / server mode and serialisation of variables etc). We also interface with an eyelink eye tracker, but that has its own network code. The problems you'll have to deal with is synchronisation, how will you ensure accurate timing between psychtoolbox and the eye tracker?
I am currently trying to link up a mac laptop that will be presenting a stimulus in MATLAB (psychtoolbox), to a PC that has eye tracking software (that can be controlled by MATLAB). Is there an easy way to achieve this using jtcp?
I greatly appreciate your help.