Singer, Sebastian skrev 2012-07-12 12:49:
> Hi all,
>
> when calling [data, count] = recv()  from the sockets package on a
> closed connection octave emits an error:
>
> error: octave_base_value::print (): wrong type argument `<unknown type>'
>
> error: called from:
> error:   socket_server.m ...
>
> I think the return array [data, count] is not initialized correctly,
> when no data could be read.  I can get rid of this error with the
> following patch:
>
> Index: sockets.cc
> ===================================================================
> --- sockets.cc        (revision 10742)
> +++ sockets.cc        (working copy)
> @@ -708,8 +708,10 @@
>
>     if(retval<0) {
>       //We get -1 if an error occurs,or if there is no data and the
>       //socket is non-blocking. We should return in both cases.
> +    return_list(0) = retval; // Make sure return_list is defined
> correctly with some value
>     } else if (0==retval) {
>       //The peer has shut down.
> +    return_list(0) = retval; // Make sure return_list is defined
> correctly with some value
>     } else {
>       //Normal behaviour.
>       Matrix return_buf(1,retval);
>
> Please advise, if this is a proper fix of the problem and if this patch
> can be accepted.
>
> I use octave-3.6.1_gcc4.6.2 (mingw) on windows 7. The sockets package
> was taken from the svn repository.
> Two short scripts for server and client are attached.
>
> In order to compile the sockets package I had to add  '-lws2_32' to the
> Makefile to avoid linker errors. What is the correct way to specify
> linker flags platform independently for octave packages?
>
>
> Regards,
> Sebastian.
>
Hi, thank you for the patch. I think you spotted a problem, but I have 
other thoughts for the solution. recv() returns the data and the count. 
It is meant that count should specify the length of the data read, or 
signal an error/no data available (-1) or remote end shutdown (0). For 
the last two, the sane thing is to let data be an empty variable. Sloppy 
users (no shame on them!) which do not call recv() with two output 
arguments will then receive an empty data vector, which is fine to 
append to other vectors etc. With your patch, the will receive 0 or -1 
which I guess will be type converted into 255.

I also do not know how to check that one is on a windows platform in the 
makefile. can you try to put the uname command in your makefile and see 
what it spits out?
Paul Dreik



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to