WIP: Comply with GNU Coding Standards
This commit is contained in:
parent
59c594c5c3
commit
0e9076d239
21
server1.c
21
server1.c
@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ENGR2782 - CN Assignment
|
||||
* Your challenge is to format the following code in a readable manner, anwsering the questions in the comments.
|
||||
*
|
||||
*/
|
||||
// server1 - server program for demonstrating data transfer over TCP/IP
|
||||
|
||||
// This program complies with the GNU Coding Standards found here:
|
||||
// https://www.gnu.org/prep/standards/html_node/index.html
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -16,11 +15,15 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
#define BUFFERT 512
|
||||
#define BACKLOG 1
|
||||
|
||||
int create_server_socket (int port);
|
||||
struct sockaddr_in sock_serv,sock_clt;
|
||||
int main(int argc, char** argv){
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int sfd, fd;
|
||||
unsigned int length = sizeof(struct sockaddr_in);
|
||||
long int n, m, count = 0;
|
||||
@ -59,7 +62,7 @@ int main(int argc, char** argv){
|
||||
/* Set the IP address to allow connections on any network interface on the server */
|
||||
sock_serv.sin_addr.s_addr = htonl(/* Q) What goes here? */);
|
||||
/* See; man 4 ip */
|
||||
|
||||
|
||||
if (bind(sfd,(struct sockaddr*)&sock_serv,l) == -1) {perror("bind fail"); exit(EXIT_FAILURE);}
|
||||
bzero(buffer,BUFFERT);
|
||||
listen(sfd,BACKLOG);
|
||||
@ -71,7 +74,7 @@ int main(int argc, char** argv){
|
||||
/* See; man 2 accept */
|
||||
|
||||
|
||||
if (nsid == -1) {perror("accept fail"); return EXIT_FAILURE;}
|
||||
if (nsid == -1) {perror("accept fail"); return EXIT_FAILURE;}
|
||||
else {
|
||||
if(inet_ntop(AF_INET,&sock_clt.sin_addr,dst,INET_ADDRSTRLEN)==NULL) {perror("erreur socket");exit (4);}
|
||||
clt_port=ntohs(sock_clt.sin_port);
|
||||
@ -99,6 +102,6 @@ int main(int argc, char** argv){
|
||||
printf("End of transmission with %s.%d\n",dst,clt_port);
|
||||
|
||||
/* Select the appropriate variable in the following function call argument */
|
||||
printf("Number of octets received : %ld \n", /* Q) What goes here? */);
|
||||
printf("Number of octets received : %ld \n", /* Q) What goes here? */);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user