i am traying to make a aplication for testing implementing a chat in andrid plataform, but a do not see the
possibility to use socket with this plataform. Please, anybody can tell me how can implement socket in my aplication test ?.
Awaiting for same answer, best regards
Luis Valseca
how can i to use socket with android plataform?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 2
- Joined: Wed Oct 03, 2012 6:28 pm
Re: how can i to use socket with android plataform?
No socket support yet, one way you could work around this would be to use an external web server and have your clients post to the server and read responses from the server. Might be able to use push notifications for chat message receipt.
I think socket support is planned, but unless it has slipped in while I wasn't paying attention, it's not there yet.
I think socket support is planned, but unless it has slipped in while I wasn't paying attention, it's not there yet.
-
- Posts: 2
- Joined: Wed Oct 03, 2012 6:28 pm
Re: how can i to use socket with android plataform?
A lot of thanks for you replay,
i need implent a application that work in android and ios plataform, livecode
is very easy to use but i need socket for my application, at the moment i will continued
with sdk of android in the environment eclpise and i will check if livecode have
more functions in the future.
Best regards
Luis Valseca , from Madrid-Spain
i need implent a application that work in android and ios plataform, livecode
is very easy to use but i need socket for my application, at the moment i will continued
with sdk of android in the environment eclpise and i will check if livecode have
more functions in the future.
Best regards
Luis Valseca , from Madrid-Spain
-
- Livecode Opensource Backer
- Posts: 1
- Joined: Fri Oct 26, 2012 7:24 pm
Re: how can i to use socket with android plataform?
I came across the same problem, between Windows and Android, I solved the problem by using FTP, and wrote a simple FTP Server program in livecode on the PC end, you can then just FTP your message to the remote computer. I only went in one direction but I can't see any reason why it would not work in both directions as a Chat program. There are a few complications with active and passive mode, but once set up all you need on the android end is to ftp your message as the contents of a file, and read the reply in the same way.
function getLocalIPAddress -- windows only
put "255.255.255.255:44444" into mySock
open datagram socket to mySock
put hostAddress(mySock) into myIP1
close socket mySock
return myIP1
end getLocalIPAddress
on startup
accept connections on port 21 with message incomming
--put empty into field "log" on card" server" on stack "server"
end startup
on incomming theIP -- incoming FTP
put theIP into field "COMMSIP"
clientConnected theIP
end incomming
on clientConnected theIP
--log "1" && theIP
write "220 -" && CRLF to socket theIP -- Wellcome request user
read from socket theIP with message gotuser
end clientConnected
on gotuser theIP, pMsg
--log "User-" && pMsg
put pMsg into field "User"
write "331 User OK" & crlf to socket theIP -- user OK request password
read from socket theIP with message gotpswd
end gotuser
on sockettimeout theip
--log"Timeout" && theip
end sockettimeout
on gotpswd TheIP, pMsg
--log "Password-" && pMsg
write "230" & crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end gotpswd
on r0 TheIP, pMsg
--log pMsg
if pMsg contains "PWD" then
r1 TheIP,pMsg
exit r0
end if
if pMsg contains "TYPE I" then
r2 TheIP,pMsg
exit r0
end if
if pMsg contains "SIZE" then
r3 TheIP,pMsg
exit r0
end if
if pMsg contains "PASV" then
put true into xferpasv
r4 TheIP,pMsg
exit r0
end if
if pMsg contains "RETR" then
r5 TheIP,pMsg
exit r0
end if
if pMsg contains "QUIT" then
r6 TheIP,pMsg
exit r0
end if
if pMsg contains "PORT" then
put false into xferpasv
r7 TheIP,pMsg
exit r0
end if
end r0
on r1 TheIP, pMsg --pwd
--log "Request 1 PWD-" && pMsg
write "257" && quote &"/" & quote & crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end r1
on r2 TheIP, pMsg --Type I
--log "Request TYPE I -" && pMsg
write "200" & crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end r2
on r3 TheIP, pMsg --file size
--log "Request 3 File Size-" && pMsg
write "213 2" && crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end r3
on r4 TheIP, pMsg --PASV
--log "Request 4 PASV -" && pMsg
put false into xfertype
put getXferIP(61235) into t1
put getLocalIPAddress() into MyIP
put "227 Entering Passive Mode" && t1 & crlf into t2
--log "sent >" && t2
write t2 to socket theIP -- Acccept Connection
accept connections on port 61235 with message filexfer
--log the result
read from socket theIP with message r0
end r4
on filexfer theIP
put theIP into field "DataIP"
end filexfer
function getLocalIPAddress -- windows only
put "255.255.255.255:44444" into mySock
open datagram socket to mySock
put hostAddress(mySock) into myIP1
close socket mySock
return myIP1
end getLocalIPAddress
on startup
accept connections on port 21 with message incomming
--put empty into field "log" on card" server" on stack "server"
end startup
on incomming theIP -- incoming FTP
put theIP into field "COMMSIP"
clientConnected theIP
end incomming
on clientConnected theIP
--log "1" && theIP
write "220 -" && CRLF to socket theIP -- Wellcome request user
read from socket theIP with message gotuser
end clientConnected
on gotuser theIP, pMsg
--log "User-" && pMsg
put pMsg into field "User"
write "331 User OK" & crlf to socket theIP -- user OK request password
read from socket theIP with message gotpswd
end gotuser
on sockettimeout theip
--log"Timeout" && theip
end sockettimeout
on gotpswd TheIP, pMsg
--log "Password-" && pMsg
write "230" & crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end gotpswd
on r0 TheIP, pMsg
--log pMsg
if pMsg contains "PWD" then
r1 TheIP,pMsg
exit r0
end if
if pMsg contains "TYPE I" then
r2 TheIP,pMsg
exit r0
end if
if pMsg contains "SIZE" then
r3 TheIP,pMsg
exit r0
end if
if pMsg contains "PASV" then
put true into xferpasv
r4 TheIP,pMsg
exit r0
end if
if pMsg contains "RETR" then
r5 TheIP,pMsg
exit r0
end if
if pMsg contains "QUIT" then
r6 TheIP,pMsg
exit r0
end if
if pMsg contains "PORT" then
put false into xferpasv
r7 TheIP,pMsg
exit r0
end if
end r0
on r1 TheIP, pMsg --pwd
--log "Request 1 PWD-" && pMsg
write "257" && quote &"/" & quote & crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end r1
on r2 TheIP, pMsg --Type I
--log "Request TYPE I -" && pMsg
write "200" & crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end r2
on r3 TheIP, pMsg --file size
--log "Request 3 File Size-" && pMsg
write "213 2" && crlf to socket theIP -- Acccept Connection
read from socket theIP with message r0
end r3
on r4 TheIP, pMsg --PASV
--log "Request 4 PASV -" && pMsg
put false into xfertype
put getXferIP(61235) into t1
put getLocalIPAddress() into MyIP
put "227 Entering Passive Mode" && t1 & crlf into t2
--log "sent >" && t2
write t2 to socket theIP -- Acccept Connection
accept connections on port 61235 with message filexfer
--log the result
read from socket theIP with message r0
end r4
on filexfer theIP
put theIP into field "DataIP"
end filexfer