Hey all...
I'm working with doing ftp-type stuff with sockets and everything was going
really well up to a point... the point where I tried to send a file from my
Mac to my server at work.
First I used Fetch and sent a file, then copied the log. I tried to
duplicate the commands step by step, and it worked until I got to the PORT
command, and that's where things fall apart.
Sockets make MetaCard EXTREMELY powerful, but it's frustrating to use
sockets because you end up running all over the Internet looking at RFC's
and a million little articles written by tons of people and getting very
confused. Or at least I do. If it hasn't been suggested before, I suggest
we find a common area and post our successful socket scripts, like the
e-mail stack that someone had a while back. For example, here's how far I
got (successfully):
--===================== Logging on to a ftp server
====================================
on mouseUp
put "" into field "log"
--create CRLF character... this is necessary because it tells the server
you're finished "talking"...
-- ... sort of like saying "over" on a walkie-talkie...
put numToChar(13) &numToChar(10)into CRLF
--what server do you want to connect (ftp) to?
put field "server" & ":21" into thisSocket
--open the socket named "thisSocket"... this is the remote socket
open socket to thisSocket
read from socket thisSocket for 1 line
put it after field "log" -- the field "log" maintains a list of your
conversation
--send your user name to the server
write "USER" && field "name" & CRLF to socket thisSocket
read from socket thisSocket for 1 line
put it after field "log"
--send your password to the server
put "PASS" && "89ok57" & CRLF into thisString -- with "89ok57" being your
password
write thisString to socket thisSocket
read from socket thisSocket for 1 line
put it after field 1
-- get the operating system and serving software from the server
write "SYST" & CRLF to socket sock
read from socket thisSocket for 1 line
put it after field 1
-- get the current directory
write "PWD" & CRLF to socket thisSocket
read from socket thisSocket for 1 line
put it after field 1
--change directory
write "CWD testme" & CRLF to socket thisSocket -- with "testme" being the
directory you want
read from socket thisSocket for 1 line
put it after field 1
-- get the current directory
write "PWD" & CRLF to socket thisSocket
read from socket thisSocket for 1 line
put it after field 1
--and then leave...
write "QUIT" & CRLF to socket thisSocket
read from socket thisSocket for 1 line
put it after field 1
close socket thisSocket
end mouseUp
--==========================================================================
=========
Obviously this is not a complete script, and it doesn't check to make sure
the server is following the "conversation"... each message from the server
starts with a number that indicates what's going on, and you can check those
numbers for errors... but anyway...
If I can figure out the rest (on sending a file), I will post it here. If
anyone else has already figured this out, would you consider sharing?
:)
Richard MacLemale
www.coolclassroom.com
This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm