
tcpcli.c File Reference
Client module. More...
Go to the source code of this file.
int main (int argc, char *argv[])
Main entry in client module.
int sockfd = 0
create the socket.
int chopt
dummy variable for options test.
int port_served = 0
port to connect.
int bflag = 0
dummy variable for number of addresses supplied.
char progname [MAXLINE]
program's name.
char addropt [MAXLINE]
bound address.
struct sockaddr_in servaddr
structure of socket address.
Client module.
Usage
example: ./tcpcli -a 127.0.0.1
Features
- Check the arguments supplied by the user
- Retrieve the program's name
- Check if 3 arguments were supplied, if not display help message and quit
- Check if the option supplied is a valid one, if not display help message and quit
- Check if address was supplied, if not display help message and quit
- Check if only one address was supplied, if not display help message and quit
- Compute the real port number
- Check if port was supplied with a dash before it, if not display help message and quit
- Print an help message on the terminal io
- Create an active socket
- Fill in the address structure, if address supplied not valid, display help message and quit
- Make a connection to the server's socket
- Write the request for the server to the socket
Definition in file tcpcli.c.
int main (int argc, char *argv[])
Main entry in client module.
Definition at line 38 of file tcpcli.c.
References: addropt[MAXLINE], bflag, chopt, port_served, progname[MAXLINE], servaddr, sockfd
cliusage(), Inet_pton(), Connect(), Socket(), str_cli()
SERV_PORT1, SERV_PORT3, SA.