Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
FTP
RFC (Request For Comments) 959
http://www.ietf.org/rfc.html
The File Transfer Protocol
was defined as a protocol for file transfer between HOSTs on the ARPANET, with the
primary function of FTP defined as transferring files efficiently and reliably among
hosts and allowing the convenient use of remote file storage capabilities.
There are 2 channels:
1.
Control Channel (port 21)
FTP commands and replies
Eg:
ftp draco
Connected to draco.ece.arizona.edu.
220 gauss FTP server (SunOS 5.8) ready.
2.
File
system
Server
PI
FTP Commands
Server
DTP
Data
Connection
Server Side
FTP Replies
User
User PI
User
DTP
Client Side
File
system
FTP
PI
Protocol Interpreter
DTP Data Transfer Process
Examples of protocol interpretation
Client
ls
get
put
Server
STAT .
retr
stor
Client
socket()
connection establishment connect()
read() data(request)
write()
blocks until connection from client
process request
write()
read()
data (reply)
Connectionless Protocol
Server
socket()
bind()
recvfrom()
Client
blocks until connection from client
bind()
data (request)
sendto()
process request
write()
data (reply)
recvfrom()
socket()
System Calls
int sendto (int socket, char *message, int nbytes, int flags, struct sockaddr
*dest, int dest_len);
Description
The sendto() function sends a message through connectionless-mode
socket.The message will be sent to the address specified by dest.
The system call takes the following arguments:
socket
Specifies the socket descriptor.
message
Points to a buffer containing the message to be sent.
nbytes
Specifies the size of the message in bytes.
System Calls
dest
Points to a sockaddr structure containing the destination address. The
length and format of the address depend on the address family of the
socket.
dest_len
Specifies the length of the sockaddr structure pointed to by the dest
argument.
flags
Values of this argument are formed by logically OR'ing zero or more
of the following flags
System Calls
int recvfrom (int socket, char *message, int nbytes int flags, struct
sockaddr *from, int *from_len);
Description
The recvfrom() function call receives a message from a connectionlessmode socket.
The recvfrom system call fills in the protocol specific address of who sent
the data into from . The length of this address is also returned to the
caller in from_len.
<stdio.h>
<sys/types.h>
<sys/socket.h>