Hi I am trying to create simple tcp client server architecture in which server accepts client request and echoes the same line written by client.
this is my code
/*HELPER.H ========
Interface to socket helper functions.
Many of these functions are adapted from, inspired by, or otherwise shamelessly plagiarised from "Unix Network Programming", W Richard Stevens (Prentice Hall).
Many of these functions are adapted from, inspired by, or otherwise shamelessly plagiarised from "Unix Network Programming", W Richard Stevens (Prentice Hall).
#include "helper.h" /* our own helper functions */
#include <stdlib.h> #include <stdio.h>
/* Global constants */
#define ECHO_PORT (2002)
#define MAX_LINE (1000)
int main(int argc, char *argv[]) { int list_s; /* listening socket */ int conn_s; /* connection socket */
short int port; /* port number */ struct sockaddr_in servaddr; /* socket address structure */ char buffer[MAX_LINE]; /* character buffer */ char *endptr; /* for strtol() */
/* Get port number from the command line, and set to default port if no arguments were supplied */
if ( argc == 2 ) { port = strtol(argv[1], &endptr, 0); if ( *endptr ) {
fprintf(stderr, "ECHOSERV: Invalid port number.\n"); exit(EXIT_FAILURE); } } else if ( argc < 2 ) { port = ECHO_PORT; } else { fprintf(stderr, "ECHOSERV: Invalid arguments.\n");
exit(EXIT_FAILURE); }
My problem is i am getting an error of undefined reference to address@hidden ..... i m running GCC on windows so if u have solution for this do write to me.