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.


Attachment: socket_server.m
Description: socket_server.m

Attachment: sockettest.m
Description: sockettest.m

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