Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27.2~pre3 (Frisky Freud)
- # Thu Mar 21 11:40:17 2013 (posix)
- # <http://www.cogsci.nl/opensesame>
- set foreground "white"
- set subject_parity "even"
- set font_size "18"
- set description "Default description"
- set title "Wait server"
- set font_family "mono"
- set font_bold "no"
- set coordinates "relative"
- set height "400"
- set mouse_backend "xpyriment"
- set start "experiment"
- set compensation "0"
- set sampler_backend "legacy"
- set keyboard_backend "legacy"
- set background "black"
- set subject_nr "0"
- set canvas_backend "xpyriment"
- set width "400"
- set synth_backend "legacy"
- set font_italic "no"
- define sketchpad done
- set duration "keypress"
- set start_response_interval "no"
- set description "Displays stimuli"
- draw textline 0.0 0.0 "Done!" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
- define inline_script inline_script
- ___run__
- import socket
- ip = '127.0.0.1' # The IP address of the other PC
- port = 40007 # An arbitrary port that matches the client
- print 'Opening socket'
- socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- # Reducing the timeout will improve synchronization
- socket.settimeout(0.1)
- print 'Listening'
- while True:
- socket.sendto('1', (ip, port))
- print 'send 1'
- try:
- s, ip = socket.recvfrom(1)
- print 'recv %s' % s
- except: # A timeout occurred
- s = None
- if s == '1':
- break
- print 'Client says hi!'
- socket.close()
- __end__
- set _prepare ""
- set description "Executes Python code"
- define sequence experiment
- run wait_keypress "always"
- run wait_connect "always"
- run inline_script "always"
- run done "always"
- define sketchpad wait_connect
- set duration "0"
- set description "Displays stimuli"
- draw textline 0.0 0.0 "Waiting for other PC" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
- define sketchpad wait_keypress
- set duration "keypress"
- set description "Displays stimuli"
- draw textline 0.0 0.0 "Press any key" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement