Re: how to access a ftp sever with socket

2014-12-08 Thread ketmar via Digitalmars-d-learn
On Mon, 8 Dec 2014 17:16:23 +0800 (CST)
michael via Digitalmars-d-learn 
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.


signature.asc
Description: PGP signature


how to access a ftp sever with socket

2014-12-08 Thread michael via Digitalmars-d-learn
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);
}

 ‍