1 / 10

Remote Shell

Remote Shell. CS230 Project #4 Assigned : 2006. 05. 15 Due date : 2006. 05. 29. server. socket(). bind(). client. socket(). listen(). accept(). connection. connect(). request data. send(). recv(). reply data. recv(). send(). Socket. Socket: a software abstraction

hanh
Télécharger la présentation

Remote Shell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Remote Shell CS230 Project #4 Assigned : 2006. 05. 15 Due date : 2006. 05. 29

  2. server socket() bind() client socket() listen() accept() connection connect() request data send() recv() reply data recv() send() Socket • Socket: a software abstraction • designed to provide a standard API for sending and receiving data across a computer network • c.f.) pipe, file, shared memory • Sockets are designed to accommodate virtually any networking protocol (i.e. TCP/IP and UDP/IP). • Implemented in many different programming languages and for most operating systems.

  3. IP, Port, and Internet Protocol • IP: • A address assigned for network interface card • 32bits address • Port • End-point of a communication operation • 16-bit number • UDP • Connectionless • Unreliable • Un-ordered packet protocol • TCP • Connection setup • Provide reliable connection • In-order byte stream protocol • Congestion Control

  4. Functions (1/3) • int socket(int domain, int type, int protocol) • create socket • type • SOCK_STREAM: TCP • SOCK_DGRAM: UDP • int bind(int sockfd, const struct sockaddr *address, size_t address_len) • associate a socket with an IP address and port number • int listen(int sockfd, int n) • tell a socket to listen for incoming connections

  5. Functions (2/3) • int accept(int sockfd, struct sockaddr *address, size_t *address_len) • accept an incoming connection on a listening socket • int connect(int sockfd, const struct sockaddr *address, size_t address_len) • connect a socket to a server • ssize_t recv(int sockfd, void *buf, size_t len, int flag) • receive data on a socket

  6. Functions (3/3) • ssize_t send(int sockfd, const void *buf, size_t len, int flags) • send data out over a socket • int close(int sockfd) • close a socket descriptor

  7. Specification (1/3) • Enhance your own shell to allow remote access of single client/server model • Supplement built-in server/client commands for your shell • e.g.) $server 12345 $client 127.0.0.1 12345 • Remote access • Server receives commands from client’s standard input • The server executes the commands • The server returns its standard output to the client • How often inputs/outputs are exchanged between client and server? Standard input Standard output client server

  8. Specification (2/3) • Supplements file transfer commands • ‘put filename’ command • Upload client’s file from client to server • If server already has a file of the same name, overwrite the existing file • ‘get filename’ command • Download server’s file from server to client • If client already has a file of the same name, overwrite the existing file • Allow ‘!’ as generic console ftp programs do to execute client’s side commands

  9. Specification (3/3) • Details • Use TCP connection • Do not use threads yet • Compile • -lxnet option

  10. Reference • http://beej.us/guide/bgnet/

More Related