bagyavinoth
Junior Member level 1
hi,
i am trying to create a simple tcp/ip client in c. i refer to the below weblink **broken link removed** which gave me a simple client.c code. but when i try to compile it using the command line tool
then i downloaded those header files that are missing and i put it in the gcc's include directory as follows sys/types.h,sys/socket.h,netinet/in.h,netdb.h.
after that when i try to compile it, the log is as follows
i am trying to create a simple tcp/ip client in c. i refer to the below weblink **broken link removed** which gave me a simple client.c code. but when i try to compile it using the command line tool
C:\>gcc -lnsl -lsocket -o client client.c
In file included from client.c:1:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:533:23: sys/ty
pes.h: No such file or directory
In file included from client.c:1:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:539: error: sy
ntax error before "off64_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:546: error: sy
ntax error before "ftello64"
client.c:3:24: sys/socket.h: No such file or directory
client.c:4:24: netinet/in.h: No such file or directory
client.c:5:19: netdb.h: No such file or directory
client.c: In function `main':
client.c:19: error: storage size of 'sin' isn't known
client.c:20: error: storage size of 'pin' isn't known
client.c:28: warning: assignment makes pointer from integer without a cast
client.c:35: error: `AF_INET' undeclared (first use in this function)
client.c:35: error: (Each undeclared identifier is reported only once
client.c:35: error: for each function it appears in.)
client.c:36: error: dereferencing pointer to incomplete type
client.c:40: error: `SOCK_STREAM' undeclared (first use in this function)
then i downloaded those header files that are missing and i put it in the gcc's include directory as follows sys/types.h,sys/socket.h,netinet/in.h,netdb.h.
after that when i try to compile it, the log is as follows
sorry i'm very new to programming.. can anybody solve this issue. i'm using windows xp.. thanx in advance....C:\>gcc -lnsl -lsocket -o client client.c
In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/
sys/socket.h:23,
from client.c:3:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:6:20: end
ian.h: No such file or directory
In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/
sys/socket.h:23,
from client.c:3:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:11: error
: syntax error before "enum"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:88: error
: syntax error before "in_port_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:89: error
: syntax error before "in_addr_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:92: error
: syntax error before "in_addr_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:96: error
: field `imr_multiaddr' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:97: error
: field `imr_interface' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:101: erro
r: field `imr_multiaddr' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:102: erro
r: field `imr_address' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:103: erro
r: syntax error before "int32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:107: erro
r: syntax error before "int32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:110: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:115: erro
r: syntax error before "sa_family_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:119: erro
r: `int16_t' undeclared here (not in a function)
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:120: erro
r: `uint16_t' undeclared here (not in a function)
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:120: erro
r: invalid application of `sizeof' to incomplete type `in_addr'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:121: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:177: erro
r: syntax error before "uint8_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:179: erro
r: syntax error before "u6_addr32"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:180: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:184: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:187: erro
r: syntax error before "uint16_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:189: erro
r: syntax error before "sin6_flowinfo"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:191: erro
r: syntax error before "sin6_scope_id"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:195: erro
r: syntax error before "sa_family_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:199: erro
r: invalid application of `sizeof' to incomplete type `sockaddr_in6'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:200: erro
r: invalid application of `sizeof' to incomplete type `in_addr'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:200: erro
r: size of array `sin_zero' is too large
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:201: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:205: erro
r: field `ipv6mr_multiaddr' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:207: erro
r: syntax error before "int32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:211: erro
r: field `flr_dst' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:212: erro
r: syntax error before "uint32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:214: erro
r: syntax error before "flr_share"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:215: erro
r: syntax error before "flr_flags"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:216: erro
r: syntax error before "flr_expires"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:217: erro
r: syntax error before "flr_linger"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:218: erro
r: syntax error before "__flr_pad"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:290: erro
r: field `ipi6_addr' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:291: erro
r: syntax error before "int32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:295: erro
r: field `ifr6_addr' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:296: erro
r: syntax error before "uint32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:305: erro
r: syntax error before "uint8_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:307: erro
r: syntax error before "type"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:308: erro
r: syntax error before "segments_left"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:313: erro
r: syntax error before "uint8_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:325: erro
r: field `rt_hdr' has incomplete type
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:326: erro
r: syntax error before "uint32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:329: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:334: erro
r: syntax error before "uint32_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:344: erro
r: syntax error before "nexthdr"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:345: erro
r: syntax error before "hop_limit"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:349: erro
r: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:359: erro
r: syntax error before "htonl"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:359: erro
r: syntax error before "hostlong"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:360: erro
r: syntax error before "htons"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:360: erro
r: syntax error before "hostshort"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:361: erro
r: syntax error before "ntohl"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:361: erro
r: syntax error before "netlong"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:362: erro
r: syntax error before "ntohs"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:362: erro
r: syntax error before "netshort"
In file included from client.c:3:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:24:19: pr
oxy.h: No such file or directory
In file included from client.c:3:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:33: error
: syntax error before "typedef"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:37: error
: syntax error before "GObject"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:40: error
: syntax error before "port"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:41: error
: conflicting types for 'addr'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:327: erro
r: previous declaration of 'addr' was here
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:43: error
: syntax error before "sockfd"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:44: error
: syntax error before "watchid"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:45: error
: syntax error before "thread"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:47: error
: syntax error before '*' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:48: error
: syntax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:51: error
: syntax error before "GObjectClass"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:55: error
: syntax error before "gint"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:58: error
: syntax error before "socket_ctx_get_type"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:60: error
: syntax error before '*' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:62: error
: syntax error before "guint16"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:63: error
: syntax error before "guint32"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:64: error
: syntax error before "guint16"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:67: error
: syntax error before "socket_ctx_set_nonblock"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:67: error
: syntax error before "gboolean"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:68: error
: syntax error before "socket_ctx_set_data"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:71: error
: syntax error before "ProxyCtx"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:72: error
: syntax error before '*' token
In file included from client.c:5:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:4:23: sys/cdef
s.h: No such file or directory
In file included from client.c:5:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:18: error: syn
tax error before "struct"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:25: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:26: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:29: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:32: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:35: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:37: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:39: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:41: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:47: error: syn
tax error before "socklen_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:50: error: syn
tax error before '}' token
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:52: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:53: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:54: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:55: error: syn
tax error before "socklen_t"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:57: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:58: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:64: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:74: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:78: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:86: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:87: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:88: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:89: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:90: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:93: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:96: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:99: error: syn
tax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:102: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:114: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:115: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:116: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:117: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:118: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:120: error: sy
ntax error before "__THROW"
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netdb.h:121: error: sy
ntax error before "__THROW"
In file included from client.c:6:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/string.h:36: error: sy
ntax error before "void"
client.c: In function `main':
client.c:19: error: storage size of 'sin' isn't known
client.c:20: error: storage size of 'pin' isn't known
client.c:28: warning: assignment makes pointer from integer without a cast
client.c:35: error: `AF_INET' undeclared (first use in this function)
client.c:35: error: (Each undeclared identifier is reported only once
client.c:35: error: for each function it appears in.)
client.c:36: error: dereferencing pointer to incomplete type
client.c:40: error: `SOCK_STREAM' undeclared (first use in this function)
client.c: At top level:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:108: erro
r: storage size of `ipi_spec_dst' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:109: erro
r: storage size of `ipi_addr' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:197: erro
r: storage size of `sin_addr' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:190: erro
r: storage size of `sin6_addr' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:200: erro
r: storage size of `sin_zero' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:347: erro
r: storage size of `saddr' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/netinet/in.h:348: erro
r: storage size of `daddr' isn't known
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/socket.h:41: error
: storage size of `addr' isn't known