how to access a ftp sever with socket
michael via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 8 01:16:23 PST 2014
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);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141208/5753846a/attachment.html>
More information about the Digitalmars-d-learn
mailing list