Download presentation
Presentation is loading. Please wait.
Published byEvangeline Henry Modified over 9 years ago
1
Remote Shell CS230 Project #4 Assigned : 2006. 05. 15 Due date : 2006. 05. 29
2
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. socket() bind() listen() accept() server client recv() send() socket() connect() send() recv() connection request data reply data
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? clientserver Standard input Standard output
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/ http://beej.us/guide/bgnet/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.