how to access a ftp sever with socket

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 8 01:32:08 PST 2014


On Mon, 8 Dec 2014 17:16:23 +0800 (CST)
michael via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
wrote:

> Hello Anyone:
>      i am trying make a ftp client with socket,i have tried std.net.curl,but i cont stand with so many try-catch structure in my code,i am not familiar with
> socket,i write a pecie of code but it cont give me the welcome message which i want,and then i use wireshark to trace the comunication,i found that
> ftp server:21 send the message to my client:1024,but why there is nothing in str buf?thanks for your help.
> import std.socket,std.stdio;
> void main(){
>  string ip = "**********";//i hide the address
>  int msecs = 1000;
>  auto ftp = getAddressInfo(ip,"ftp");
>  Socket listener = new TcpSocket;
>  listener.bind(new InternetAddress(1024));
>  listener.connect(ftp[0].address);
>  auto pair = socketPair();
>  auto sock = pair[0];
>  sock.setOption(SocketOptionLevel.SOCKET,SocketOption.RCVTIMEO, dur!"msecs"(msecs));
>  char[1024] buf;
>  sock.receive(buf);
>  writeln(buf);
> }

that is not how it all works. you need to learn network programming
with sockets first, it is not D-specific. for now it looks like you are
trying random things in a hope that it will magically works.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141208/8b75dd7c/attachment.sig>


More information about the Digitalmars-d-learn mailing list