Search found 107 matches

by csfreebird
Wed Jan 23, 2013 11:21 am
Forum: newLISP in the real world
Topic: How to know the TCP connection was closed?
Replies: 4
Views: 2162

Re: How to know the TCP connectio was closed?

net-receive works for me. (if (net-receive s buffer 2) (println "failed, the connection should be closed, time:" (date (date-value))) (println "succeeded, the connection was closed:" (net-error))) But net-peek doesn't. It returns 0 instead of nil when connection has been closed by server. (println (...
by csfreebird
Wed Jan 23, 2013 6:27 am
Forum: newLISP in the real world
Topic: How to know the TCP connection was closed?
Replies: 4
Views: 2162

How to know the TCP connection was closed?

Hello I have a test app programmed by newlisp. It connects to the server via TCP first, never sends request to server until server close the connection when timeout. I read the API doc, but don't know which API could help me to determine the current connection's status. Should I call net-send or net...
by csfreebird
Sat Jan 19, 2013 2:33 pm
Forum: newLISP in the real world
Topic: Send byte array via TCP
Replies: 8
Views: 3379

Re: Send byte array via TCP

It's done.
Will go ahead with this.
I am about to simulate over 20,000 devices using newLISP, they will be used to test against my TCP server.
by csfreebird
Sat Jan 19, 2013 1:37 pm
Forum: newLISP in the real world
Topic: Send byte array via TCP
Replies: 8
Views: 3379

Re: Send byte array via TCP

It works now.

Code: Select all

> (set 'socket (net-connect "localhost" 8889))
16
> (set 'size (pack ">d" 19))
"\000\019"
> (net-send socket size)
2
pack returns a string buffer that contains my two bytes, net-send sends the string to server.
My C++ server got two bytes, 0 and 19.
Thanks.
by csfreebird
Sat Jan 19, 2013 12:42 pm
Forum: newLISP in the real world
Topic: Send byte array via TCP
Replies: 8
Views: 3379

Re: Send byte array via TCP

Thanks for so quick reply.
But after packaging my short integer, I need a way to send the bytes to server via TCP.
net-send always needs a string.
And the pack returns a string too.

Code: Select all

>(pack ">d" 5)
"\000\005"
Which API could let me to send my byte array?
I am new to newLISP.
by csfreebird
Sat Jan 19, 2013 11:03 am
Forum: newLISP in the real world
Topic: Send byte array via TCP
Replies: 8
Views: 3379

Send byte array via TCP

Hello
I want to send two bytes which represent an unsigned short in big-endian to server via TCP. But net-send only supports string parameter.
Could anyone tell me how to do this?
by csfreebird
Wed Jan 16, 2013 12:02 pm
Forum: newLISP in the real world
Topic: No easy way to copy directory
Replies: 0
Views: 2204

No easy way to copy directory

I didn't find one convenient way to copy a directory recursively. Have to execute a 'cp -r' command on Ubuntu,
Could you provide some better APIs for manupulating files.