socket script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

socket script

Started by Hamachi, 08 February, 2012, 13:23:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hamachi

Hey hope some like to help :)

I try to make a socket script there connect to irc server, need to be online all the time.

My script works as lua script.lua but then i run it whit px it make px not responde.
some of the code:
    -- Run main loop
    while true do
        local l = s:receive()
        --some code
    end

Hope someone can help or say it not will work

PPK

You are creating never ending loop in script, so PtokaX is blocked by that script and can't work  ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Hamachi

Yes :D

But how to make a socket connection then ?

the connection need to be open all the time....

PPK

Create socket, connect to server and then on timer (for example every second) try to read or send data on that socket (basically that is how PtokaX works) :P
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Hamachi

ok thanks :)

I have a another script there download a file whit socket, if it take longtime it not response too.
Have you any ide for that ?

I use timeout in one script but in this i need the file...

PPK

It is always same. Create socket, connect socket, set it nonblocking (or zero timeout with select) and then in some intervals try to read/write. Never do loops on read/writes  ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Hamachi

Ok I will look in to it :)

Thanks for you help and time PPK

Hamachi

It works almost now :)

First time it find/write it dont respone in some time and then post it. :(

i dont understand this:
set it nonblocking (or zero timeout with select)

PPK

It is in luasocket docs :P
QuoteChanges the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods send, receive, and accept will block indefinitely, until the operation completes. The settimeout method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code.
Looks like real non-blocking is always not supported, so low (zero ?) timeout is needed ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Hamachi

Thanks agen PPK :)

Now i only have some text problems hehe :)

1 (1-15) need to remove them

SMF spam blocked by CleanTalk