> -----Original Message-----
> From: Paul Dreik [mailto:sl...@pauldreik.se]
> Sent: Tuesday, July 17, 2012 2:59 PM

 [...]

> I cleaned up a bit. Can you please test the following patch?
> Index: sockets.cc
> ==========================================================
> =========
> --- sockets.cc  (revision 10746)
> +++ sockets.cc  (arbetskopia)
> @@ -678,7 +678,7 @@
>       s = &((octave_socket &)rep);
>     }
>     else if ( args(0).is_scalar_type() )
> -  {
> +    {//what happens if fd does not exist in socket_map?
>       int fd = args(0).int_value();
>       s = socket_map[fd];
>     }
> @@ -703,24 +703,29 @@
> 
> 
>     octave_value_list return_list;
> +  uint8NDArray data;
> +
>     //always return the status in the second output parameter
>     return_list(1) = retval;
>     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) = data;
>     } else if (0==retval) {
>       //The peer has shut down.
> +    return_list(0) = data;
>     } else {
>       //Normal behaviour.
> -    Matrix return_buf(1,retval);
> -
> +    dim_vector d;
> +    d(0)=retval;
> +    data.resize(d);
> +
> +    //this could possibly be made more efficient with memcpy and
> +    //fortran_vec() instead.
>       for ( int i = 0 ; i < retval ; i++ )
> -      return_buf(0,i) = buf[i];
> +      data(i) = buf[i];
> 
> -    octave_value in_buf(return_buf);
> -    octave_value out_buf;
> -    OCTAVE_TYPE_CONV( in_buf, out_buf, uint8 );
> -    return_list(0) = out_buf;
> +    return_list(0) = data;
>     }
> 
>     delete[] buf;
> 

I tried your patch. It works well for me. Obviously returning an empty
vector is better than setting return_list(0)  to retval as I did before.
Thanks for the patch.

Linker Flag:
As I compile the paket with 'pkg install sockets.tgz', I do not get the
output of make. But running uname on command line returns
'MINGW32_NT-6.1'. 
uname inside octave gives: 
octave:1> uname
ans =
  scalar structure containing the fields:

    sysname = unknown
    nodename = unknown
    release = unknown
    version = unknown
    machine = unknown

Maybe my octave  configuration is not correct. 

Regards,
Sebastian Singer.


------------------------------------------------------------------------------
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