problems with sockets on panther

Pierre Sahores psahores at easynet.fr
Mon Jul 19 23:22:24 EDT 2004


Le 20 juil. 04, ˆ 04:35, Andre Garzia a Žcrit :

>
>
> I think you can't listen and open connections at the same time... do 
> like this, change port, then launch server then connect from your 
> favorite browser...

The same idea, there and be carefull not to have an other deamon 
listening on the port you are trying to use (aka Apache)

Test something like this, below :

> on newconnect s
>   read from socket s for 1 line with message "serverread"
> end newconnect
>
>
>
> on serverread x,y
>   global PostIn,Retour,Lepath,MajDesIndexs1
>   put urldecode(y) into PostIn
>   put cr into char (length(PostIn))-1 to (length(PostIn)) of PostIn
>   put "" into Retour
>   set itemdelimiter to "&"
>   iStreamSwitch -- the application's logic goes there
>   write Retour to socket x
>   close socket x # x = adresse IP & "|" & n¡ d'ordre du socket 
> encapsulant l'Žchange de donnŽes
>   if the num of lines in (opensockets()) > 1
>     then close socket line 2 of (opensockets())
>     else exit repeat
>   end repeat
> end serverread
>
>
> on socketTimout
> end socketTimout
>
>
>
> on PreOpenStack
>   if the short name of this stack is not "istreamserver" then pass 
> PreOpenStack
>   global Lepath,dbUsers
>   put " Please, wait. iStream app's server loading..." into fld 
> "status"
>   set twelveHourTime to false
>   put "iStream app's server up since" && the short date & "," && the 
> short time into binfo
>   get the filename of this stack
>   set the itemDelimiter to "/"
>   delete last item of it
>   set the defaultFolder to it
>   put it & "/" into Lepath
>   open file Lepath & "iStreamUsers.txt" for read -- 1
>   read from file Lepath & "iStreamUsers.txt" until eof
>   put it into dbUsers
>   put " " & the result after Pboot
>   close file Lepath & "iStreamUsers.txt"
>   set the socketTimeoutInterval to "10"
>   if the num of lines in the windows is "1"
>   then
>     accept connections on port "948" with message "newconnect"
>     put "with proxying keycode 3 actived..." into thep
>   else
>     accept connections on port "9482" with message "newconnect"
>     put "with proxying keycode 7 actived..." into thep
>   end if
>   openstack
>   if the result is not "" then
>     open file Lepath & "iStreamLog.txt" for append -- 2
>     write cr & the result & cr to file Lepath & "iStreamLog.txt"
>     put " " & the result after Pboot
>   else
>     open file Lepath & "iStreamLog.txt" for append
>     write return & return & "Open sockets :" && the opensockets & 
> return & return to file Lepath & "iStreamLog.txt"
>   end if
>   close file "iStreamLog.txt"
>   replace " eof" with "" in Pboot
>   if the num of words in Pboot > 0 or DbUsers is ""
>   then put "iStream app's server not up :" & Pboot into fld "status"
>   else put binfo && thep into fld "status"
>   put the files into ERBList
>   filter ERBList with "*ERB.rev"
>   repeat for each line l in ERBList
>     if l is not in the stacksinuse then start using l
>   end repeat
>   insert the script of stack the short name of this stack into back
> end PreOpenStack
>
>
>
> on openstack
>   if the short name of this stack is "iStreamServer" then
>     if the num of lines in the windows > 1 then hide window "Home"
>     set the tool to "browse"
>   end if
> end openstack
>
>
>
> on opencard
>   if the environment is not "development" then start using "libURL"
> end opencard
>
>
>
> on ERBSrvUpdate
>   global Lepath,Retour
>   set the defaultfolder to char 1 to -2 of Lepath
>   put the files into ERBList
>   filter ERBList with "*ERB.rev"
>   repeat for each line l in ERBList
>     if l is not in the stacksinuse then start using l
>   end repeat
>   repeat for each line l in the stacksinuse
>     if l is not in ERBList then stop using l
>   end repeat
>   put "ERB's active components :" & return & return & the stacksinuse 
> & return & return & \
>       "ERB's successfully updated." into Retour
> end ERBSrvUpdate

>
> try that...
>
> cheers
> andre
>
>
> On Jul 19, 2004, at 11:25 PM, Bjšrnke von Gierke wrote:
>
>> I can't get my socket code to work.... maybe someone of you can give 
>> me a hint why I do not see anything in the opensockets?
>>
>> "server" button:
>> on mouseUp
>>   accept connections on port 80 with message "webConnect"
>>   put "Accepting" & return before field "log"
>> end mouseUp
>>
>> on webConnect RemoteIP
>>     put "socket:" && the opensockets & return before field "log"
>>   put RemoteIP & return before field "log"
>>   read from socket remoteIP until ":"
>>   put it & return before field "log"
>> end WebConnect
>>
>>
>>
>> "client" button :
>>
>> on mouseUp
>>   open socket to "192.168.1.2:80"
>>   put theSocket & return & mess
>>   write mess to Socket theSocket
>> end mouseUp
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
> -- 
> Andre Alves Garzia ð 2004
> Soap Dog Studios - BRAZIL
> http://studio.soapdog.org
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list