cannot start listen command
charles reid
charlesreid1 at gmail.com
Thu Sep 4 12:28:59 CDT 2008
The original author of the sockets package put together a test program,
which can be found here (
http://article.gmane.org/gmane.comp.gnu.octave.sources/60) and is included
below. Also, you might try 'man listen' from a Unix command line, since
it's the Unix listen that the sockets package is calling.
## Tests for octave sockets
##
function test_octave_socket()
page_screen_output = 0
load_socket_constants
fail = 0
# Create the sockets
## Server socket
server = socket(AF_INET, SOCK_STREAM, 0)
if( server < 0 )
++fail
return
end
rc = bind(server,9001)
if( rc ~= 0 )
++fail
return
end
rc = listen(server,1)
if( rc ~= 0 )
++fail
return
end
## Client socket
client = socket(AF_INET, SOCK_STREAM, 0)
if( client < 0 )
++fail
return
end
# Create the connection and accept the connection
server_info = struct("addr","127.0.0.1", "port",9001)
rc = connect(client, server_info)
if( rc ~= 0 )
++fail
return
end
server_data = accept(server)
if( server_data < 0 )
++fail
return
end
# Send and receive data
## Send as string from client
msg = "Hello socket-land!"
rc = send( client, msg )
if( rc ~= length(msg) )
++fail
return
end
## Receive at server
[msg_s, len_s] = recv( server_data, 100 )
if( msg_s == -1 || len_s ~= length(msg) )
++fail
return
end
## Send back out from server
rc = send( server_data, msg_s )
if( rc ~= length(msg_s) )
++fail
return
end
## Receive at client
[msg_c, len_c] = recv( client, 100 )
if( msg_c == -1 || len_c ~= length(msg) )
++fail
return
end
## Compare original string with recv string
msg_in = num2str( msg_c, '%c' )
if( msg_in ~= msg )
++fail
return
end
rc = disconnect( client )
rc = disconnect( server_data )
rc = disconnect( server )
printf( 'Number of failures: %d\n', fail )
end
Hope this helps.
Charles
On Thu, Sep 4, 2008 at 10:56 AM, charles reid <charlesreid1 at gmail.com>wrote:
> Hi Sverker -
>
> Don't you want listen('127.0.0.1','fork')?
>
>
> Charles
>
>
> On Thu, Sep 4, 2008 at 7:24 AM, Ben Abbott <bpabbott at mac.com> wrote:
>
>>
>>
>> On Sep 4, 2008, at 8:29 AM, Sverker Sikström <sverker.sikstrom at lucs.lu.s
>> e> wrote:
>>
>> > Dear Ben
>> >
>> > Thanks a lot for you very helpfull instruction of how to get going
>> > with the Listen command a few weeks back. I did get command
>> > "started" using your help, however, I have not been able get it
>> > going yet. I would very much appreciate a helping hand here.
>> >
>> > My goal is to have Php programm communciating with Octave, so that
>> > one can that when a visotor click on a webpage than this webpage can
>> > send string to Octave that makes a calcualtion and send its back to
>> > the webpage (where we use Php) at the webpage. Also I would like to
>> > have the Ocatve code running all the time, or at least have access
>> > to large amount of data in the internal memory without having to
>> > make a slow load from the harddrive between the calls. Also there
>> > may be several user access this information at the same time.
>> >
>> > I am not sure how to do this. But I think the Listen command would
>> > be the way to go. Is that correct?
>> >
>> > I try to run listen with:
>> >
>> > octave-3.0.1:1> pkg load sockets
>> > listen('128.0.0.1','fork')
>> > error: connect: expecting a octave_socket or integer
>> > octave-3.0.1:2>
>> >
>> > But I get an error message (see above). I guess I have the wrong
>> > call, or perhapse I need to initaitve something before.
>> >
>> > Once this code in the Octave is up and running. Then how do you call
>> > this rotine from Php?
>> >
>> > I would appreciate help on this topic very much. If you do not know
>> > how to set this up, please suggest someone that could help us out on
>> > this.
>> >
>> > Sincerely, Sverker Sikström
>> >
>> > Ben Abbott skrev:
>> >>
>> >> On Aug 11, 2008, at 5:05 AM, Sverker Sikström wrote:
>> >>
>> >>> Hi
>> >>>
>> >>> This is probabaly a very simple questions, but I am stuck and new to
>> >>> Octave. I am trying to run the command 'listen'
>> >>> (http://octave.sourceforge.net/doc/f/listen.html) on Octave. But
>> >>> it does
>> >>> not seem to find the command:
>> >>>
>> >>> octave-3.0.1:46> listen
>> >>> error: `listen' undefined near line 46 column 1
>> >>> octave-3.0.1:46>
>> >>>
>> >>> Have I not installed Octave correctly? I am using mac 0s 10.5. 4.
>> >>> Any
>> >>> help is appreciated!
>> >>>
>> >>> Sverker
>> >>
>> >> I haven't tried to do this under Mac OS X, but you'll need to
>> >> install the sockets package from Octave-Forge. The "listen" command
>> >> is part of that package (it is not part of Octave's core functions).
>> >>
>> >> http://octave.sourceforge.net/sockets/index.html
>> >>
>> >> To install see "help pkg"
>> >>
>> >> Ben
>>
>> Unfortunately, I'm not knowledgeable in what you'd like to do ..., so
>> I've cc'd Octave's help list. Hopefully someone will be able to answer
>> your questions.
>>
>> Ben
>> _______________________________________________
>> Help-octave mailing list
>> Help-octave at octave.org
>> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20080904/e6618f0d/attachment.html
More information about the Help-octave
mailing list