aucli - printf"connection with the server...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<stdlib.h> #include<netinet/in.h> #include<sys/types.h> #include<sys/socket.h> #include<netdb.h> #include<string.h> #define PORT 35699 #define MAX 1000 struct Request { char method[10]; char file[10]; char data[1000]; char username[20]; char password[20]; }; struct Response { char data[1000]; // char username1[20]; // char password1[20]; }; int main() { int sockfd; struct sockaddr_in server,client; struct Request req; struct Response res; sockfd=socket(AF_INET,SOCK_STREAM,0); if(sockfd==-1) { printf("socket creation failed. ..\n"); exit(0); } else printf("Socket successfully created. .\n"); bzero(&server,sizeof(server)); server.sin_family=AF_INET; server.sin_addr.s_addr=inet_addr(""); server.sin_port=htons(PORT);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { printf("connection with the server failed. ..\n"); exit(0); } else printf("connected to the server. .\n"); printf("\nEnter the username:"); scanf("%s",req.username); printf("\nEnter the password"); scanf("%s",req.password); send(sockfd,&req,sizeof(req),0); printf("\nEnter the method: "); scanf("%s",req.method); printf("\nEnter the file path: "); scanf("%s",req.file); if(!strcmp(req.method,"POST")) { printf("\nEnter data, use ~ to terminate: "); fflush(stdin); scanf("%[^~]",; } send(sockfd,&req,sizeof(req),0); recv(sockfd,&res,sizeof(res),0); printf("Response: %s",; close(sockfd); }...
View Full Document

This note was uploaded on 10/12/2011 for the course CSE 656 taught by Professor Ccna during the Spring '10 term at Anna University Chennai - Regional Office, Coimbatore.

Page1 / 2

aucli - printf"connection with the server...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online