expyriment.io.extras.TcpServer¶
-
class
expyriment.io.extras.
TcpServer
(port, default_package_size=None, start_listening=True)¶ A class implementing a TCP network server for a single client.
-
__init__
(port, default_package_size=None, start_listening=True)¶ Create a TcpServer.
-
clear
()¶ Read the stream empty.
-
close
()¶ Close the connection to the client.
-
default_package_size
¶ Getter for default_package_size.
-
is_connected
¶ Getter for is_connected.
-
listen
()¶ Listen for a connection on port.
-
logging
¶ Getter for logging.
-
port
¶ Getter for port.
-
send
(data)¶ Send data.
-
set_logging
(onoff)¶ Set logging of this object on or off
Parameters: onoff : bool
set logging on (True) or off (False)
Notes
See also design.experiment.set_log_level fur further information about event logging.
-
wait
(length, package_size=None, duration=None, callback_function=None, process_control_events=True)¶ Wait for data.
Parameters: length : int
The length of the data to be waited for in bytes. If not set, a single package will be waited for.
package_size : int, optional
The size of the package to be waited for, optional. If not set, the default package size will be used. If length < package_size, package_size = length.
duration: int, optional
The duration to wait in milliseconds.
callback_function : function, optional
function to repeatedly execute during waiting loop
process_control_events : bool, optional
process
io.Keyboard.process_control_keys()
andio.Mouse.process_quit_event()
(default = True)Returns: data : str
The received data.
rt : int
The time it took to receive the data in milliseconds.
Notes
This will also by default process control events (quit and pause). Thus, keyboard events will be cleared from the cue and cannot be received by a Keyboard().check() anymore!
-