Failed to create socket while using the Fieldtrip buffer
A. Stolk
A.Stolk at EWI.UTWENTE.NL
Tue Jun 23 22:50:16 CEST 2009
Hi Robert,
Thank you for your quick reply. I altered util.c, however without any luck so far. Have not tried playing with the usleep setting (yet). Let you know when I know more.
Arjen
________________________________
Van: FieldTrip discussion list namens Robert Oostenveld
Verzonden: di 6/23/2009 7:06
Aan: FIELDTRIP at NIC.SURFNET.NL
Onderwerp: Re: [FIELDTRIP] Failed to create socket while using the Fieldtrip buffer
Hi Arjan,
The same problem has recently been reported to me by Marco Rontado
(see CC). Perhaps it would be usefull if you and Marco get in touch
directly to exchange experiences, since sofar there are only few users
of fieldtrip for realtime.
I have done most of the testing of the buffer on Linux and OSX, and
there I have not observed the problem. But given that the problem not
always occurs, it might be that the problem is not only windows
specific. I am not an expert on TCP/IP networking, but what I suspect
is that simultaneous access to the buffer for writing (rt_signalproxy)
and reading (rt_signalviewer) causes the problem. Simultaneous access
should be possible, because each request is handled by a separate
thread. But opening the connection and starting the thread still takes
some time, and if during that time the other connection request comes
in, the two might collide. At least that is what I currently think is
the problem.
The solution (not yet implemented) is to have the buffer access
function detect that the read or write request has failed and then
retry. The fastest (CPU-wise) is to implement the retry at the level
of the c-code. Alternative, it would be possible to detect the problem
at the level of the matlab code. Extending the matlab wrapper around
the buffer request is simpler, but the first is cleaner. It requires a
change to the open_connection function in realtime/buffer/src/util.c.
At the moment I have limited time (due to traveling), so you could try
to fix it yourself. The code around line 258 reads
if (connect(s, (struct sockaddr *)&sa, sizeof sa)<0) {
perror("open_connection");
return -2;
}
/*
while (connect(s, (struct sockaddr *)&sa, sizeof sa) < 0) {
perror("open_connection connect");
usleep(1000000);
}
*/
If you comment out the first section and use the second code snippet
instead, then probably it will be solved. Better would be to retry
only a few times and not infinitely. Also the usleep could be changed
to reduce the delay in the retry.
I hope this helps. If you cannot get it to work, please let me know.
I'll probably be able to fix it in the official fieldtrip release
version somewhere next week.
best regards,
Robert
----- A. Stolk <A.Stolk at EWI.UTWENTE.NL> wrote:
> Dear fieldtrip users,
>
> When using the realtime functions I have difficulties using the
> fieldtrip buffer continuously. For example, putting data in the
> buffer with rt_signalproxy seems to be a smooth and stable operation
> when performed alone.
>
> But when I subsequently try to access and plot that same data (e.g.
> with t_signalviewer) with another matlab session, matlab gives an
> error after some time. This 'some time' seems to be steady in length
> everytime I try; about 60 seconds on my laptop.
>
> ??? Error using ==> buffer
> ERROR: failed to create socket
>
> Error in ==> read_header at 939
> orig = buffer('get_hdr', [], host, port);
> Error in ==> rt_signalviewer at 75
> hdr = read_header(cfg.headerfile, 'headerformat', cfg.headerformat,
> 'cache', true);
>
> I have had this problem on multiple pc's now. All are using Windows
> XP 32-bit, Fieldtrip version 20090610. Can anyone help me resolve
> this issue?
>
> Friendly regards,
>
> Arjen
>
>
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users
> of the FieldTrip toolbox, to share experiences and to discuss new
> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html
> and http://www.ru.nl/neuroimaging/fieldtrip.
>
----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
More information about the fieldtrip
mailing list