Sockets! Confused..
Posted: Fri Feb 03, 2012 4:19 pm
Hi,
I am looking for help using sockets. I have read the documentation and posts on this fourm and got a good start but I am now stuck and confused.
I have a network appliance that spits out a string of text for every transaction it handles. My aim is to write a simple stack to connect to it and read every string it throws out and add it a MySQL db for analysis later.
The stack I have connects, waits until it gets a string then displays it (for debug) then does nothing. This naybe a problem with my miss understanding of handlers or something simple! i just need pointing in the right direction please.
My Code Below:
Ok so basically this stack has a fld called "fldData" that displays: "#14:32:01> Time out.." every 10 seconds until a transaction is completed then a string is read and displayed in fldData then nothing happens. No more time out messages, no socketError etc..
Any pointers?
Thanks, And sorry if this is a newb question!
I am looking for help using sockets. I have read the documentation and posts on this fourm and got a good start but I am now stuck and confused.
I have a network appliance that spits out a string of text for every transaction it handles. My aim is to write a simple stack to connect to it and read every string it throws out and add it a MySQL db for analysis later.
The stack I have connects, waits until it gets a string then displays it (for debug) then does nothing. This naybe a problem with my miss understanding of handlers or something simple! i just need pointing in the right direction please.
My Code Below:
Code: Select all
on mouseUp
if the openSockets contains fld "fldSockets" then
put "#" & the long system time & "> already connected" & cr before fld "fldData"
send "gotSocketData" to me
else
open socket to "10.16.2.254:1752" with message "gotSocketData"
put the openSockets into fld "fldSockets"
end if
end mouseUp
on gotSocketData pSocket
read from socket pSocket until return with message "processData"
wait for messages
end gotSocketData
on processData pSocket, pData
put pData & cr before fld "fldData"
--Insert to MySQL
end processData
on socketError
put "##Socket Error##" before fld "fldData"
end socketError
on socketTimeout
put "#" & the long system time & "> Time out.." & cr before fld "fldData"
end socketTimeout
Any pointers?
Thanks, And sorry if this is a newb question!