jamesbon
October 30th, 2010, 03:44 PM
The network programming book of Richard Stevens had some errors in its functions.
Volume three code is available on internet as ttcpcliserv.tar
http://www.kohala.com/start/ttcpcliserv.tar
I found many example codes on this tar ball were using
err_sys and err_quit functions which were defined in the header
as file cliserv.h as
void err_quit(const char *, ...);
void err_sys(const char *, ...);
I could not understand above type of declaration of err_quit and err_sys (never seen such a function definition)
Replaced these words by printf in all c codes of above tar ball
sed -i 's/err_sys/printf/g' ./*.c
sed -i 's/err_quit/printf/g' ./*.cThe programs which I have read with first chapter of Vol3 of book
now seem to have worked and the header file cliserv.h which was included in each source code of example
of book
had declaration of
including the header files as
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
so I added this to each c file of that tar ball.So till now all the codes which I have tried to work or make work have worked till here.
Now the actual question begins e tar ball is coming with a
Makefile to be able to compile the source codes with examples in book with make.
When I compile that Makefile I get some errors what should I modify in the Makefile if any one can understand I am giving the Makefile and the corresponding errors
# Change the following as required:
CC = gcc
CFLAGS = -Wall
#CFLAGS = -ansi -Wall -Dsun -D__STDC__=0 -DMSG_EOF=0
# My flags for gcc/solaris 2.3: -ansi -Wall -Dsun -D__STDC__=0
# (Solaris -DMSG_EOF just to let me compile it under Solaris; it won't run)
# Add in -DGCC_STRUCT_PROBLEM for gcc versions 1.x under SunOS 4.x
# Add in -D__STDC__=0 for gcc under Solaris 2 (for Sun's screwy headers)
# Add in -D_BSD=44 for AIX 3.2.2 (see <sys/socket.h>)
# Add in -D_SOCKADDR_LEN for DEC OSF/1 (see <sys/socket.h>)
# Following line for SVR4, Solaris 2.x; 2.5 no longer requires libucb.a.
#LIBS = ./libmisc.a /usr/ucblib/libucb.a -lsocket -lnsl
# Following line for 4.4BSD, BSD/386, SunOS 4.x, AIX 3.2.2, OSF/1
LIBS = ./libmisc.a
PROGS = udpcli udpserv tcpcli tcpserv ttcpcli ttcpserv \
ttcpclibig ttcpservbig ttcphttpcli \
udpclitime udpservtime tcpclitime tcpservtime ttcpclitime ttcpservtime
all: ${PROGS}
udpcli: udpcli.o
${CC} ${CCFLAGS} -o $@ udpcli.o ${LIBS}
udpserv: udpserv.o
${CC} ${CCFLAGS} -o $@ udpserv.o ${LIBS}
tcpcli: tcpcli.o readstream.o
${CC} ${CCFLAGS} -o $@ tcpcli.o readstream.o ${LIBS}
tcpserv: tcpserv.o readstream.o
${CC} ${CCFLAGS} -o $@ tcpserv.o readstream.o ${LIBS}
ttcpcli: ttcpcli.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpcli.o readstream.o ${LIBS}
ttcpserv: ttcpserv.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpserv.o readstream.o ${LIBS}
ttcpclibig: ttcpclibig.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpclibig.o readstream.o ${LIBS}
ttcpservbig: ttcpservbig.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpservbig.o readstream.o ${LIBS}
ttcphttpcli: ttcphttpcli.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcphttpcli.o readstream.o ${LIBS}
udpclitime: udpclitime.o timer.o
${CC} ${CCFLAGS} -o $@ udpclitime.o timer.o ${LIBS}
udpservtime: udpservtime.o timer.o
${CC} ${CCFLAGS} -o $@ udpservtime.o timer.o ${LIBS}
tcpclitime: tcpclitime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ tcpclitime.o readstream.o timer.o ${LIBS}
tcpservtime: tcpservtime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ tcpservtime.o readstream.o timer.o ${LIBS}
ttcpclitime: ttcpclitime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ ttcpclitime.o readstream.o timer.o ${LIBS}
ttcpservtime: ttcpservtime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ ttcpservtime.o readstream.o timer.o ${LIBS}
clean:
rm -f ${PROGS} core core.* *.o temp.* *.out typescript*and error when I compile this is
gcc -o udpcli udpcli.o ./libmisc.a
gcc: ./libmisc.a: No such file or directory
make: *** [udpcli] Error 1
What should I modify in Makefile to make it work?
My machine is Ubuntu 10.04 64 bit
gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Volume three code is available on internet as ttcpcliserv.tar
http://www.kohala.com/start/ttcpcliserv.tar
I found many example codes on this tar ball were using
err_sys and err_quit functions which were defined in the header
as file cliserv.h as
void err_quit(const char *, ...);
void err_sys(const char *, ...);
I could not understand above type of declaration of err_quit and err_sys (never seen such a function definition)
Replaced these words by printf in all c codes of above tar ball
sed -i 's/err_sys/printf/g' ./*.c
sed -i 's/err_quit/printf/g' ./*.cThe programs which I have read with first chapter of Vol3 of book
now seem to have worked and the header file cliserv.h which was included in each source code of example
of book
had declaration of
including the header files as
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
so I added this to each c file of that tar ball.So till now all the codes which I have tried to work or make work have worked till here.
Now the actual question begins e tar ball is coming with a
Makefile to be able to compile the source codes with examples in book with make.
When I compile that Makefile I get some errors what should I modify in the Makefile if any one can understand I am giving the Makefile and the corresponding errors
# Change the following as required:
CC = gcc
CFLAGS = -Wall
#CFLAGS = -ansi -Wall -Dsun -D__STDC__=0 -DMSG_EOF=0
# My flags for gcc/solaris 2.3: -ansi -Wall -Dsun -D__STDC__=0
# (Solaris -DMSG_EOF just to let me compile it under Solaris; it won't run)
# Add in -DGCC_STRUCT_PROBLEM for gcc versions 1.x under SunOS 4.x
# Add in -D__STDC__=0 for gcc under Solaris 2 (for Sun's screwy headers)
# Add in -D_BSD=44 for AIX 3.2.2 (see <sys/socket.h>)
# Add in -D_SOCKADDR_LEN for DEC OSF/1 (see <sys/socket.h>)
# Following line for SVR4, Solaris 2.x; 2.5 no longer requires libucb.a.
#LIBS = ./libmisc.a /usr/ucblib/libucb.a -lsocket -lnsl
# Following line for 4.4BSD, BSD/386, SunOS 4.x, AIX 3.2.2, OSF/1
LIBS = ./libmisc.a
PROGS = udpcli udpserv tcpcli tcpserv ttcpcli ttcpserv \
ttcpclibig ttcpservbig ttcphttpcli \
udpclitime udpservtime tcpclitime tcpservtime ttcpclitime ttcpservtime
all: ${PROGS}
udpcli: udpcli.o
${CC} ${CCFLAGS} -o $@ udpcli.o ${LIBS}
udpserv: udpserv.o
${CC} ${CCFLAGS} -o $@ udpserv.o ${LIBS}
tcpcli: tcpcli.o readstream.o
${CC} ${CCFLAGS} -o $@ tcpcli.o readstream.o ${LIBS}
tcpserv: tcpserv.o readstream.o
${CC} ${CCFLAGS} -o $@ tcpserv.o readstream.o ${LIBS}
ttcpcli: ttcpcli.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpcli.o readstream.o ${LIBS}
ttcpserv: ttcpserv.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpserv.o readstream.o ${LIBS}
ttcpclibig: ttcpclibig.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpclibig.o readstream.o ${LIBS}
ttcpservbig: ttcpservbig.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcpservbig.o readstream.o ${LIBS}
ttcphttpcli: ttcphttpcli.o readstream.o
${CC} ${CCFLAGS} -o $@ ttcphttpcli.o readstream.o ${LIBS}
udpclitime: udpclitime.o timer.o
${CC} ${CCFLAGS} -o $@ udpclitime.o timer.o ${LIBS}
udpservtime: udpservtime.o timer.o
${CC} ${CCFLAGS} -o $@ udpservtime.o timer.o ${LIBS}
tcpclitime: tcpclitime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ tcpclitime.o readstream.o timer.o ${LIBS}
tcpservtime: tcpservtime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ tcpservtime.o readstream.o timer.o ${LIBS}
ttcpclitime: ttcpclitime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ ttcpclitime.o readstream.o timer.o ${LIBS}
ttcpservtime: ttcpservtime.o readstream.o timer.o
${CC} ${CCFLAGS} -o $@ ttcpservtime.o readstream.o timer.o ${LIBS}
clean:
rm -f ${PROGS} core core.* *.o temp.* *.out typescript*and error when I compile this is
gcc -o udpcli udpcli.o ./libmisc.a
gcc: ./libmisc.a: No such file or directory
make: *** [udpcli] Error 1
What should I modify in Makefile to make it work?
My machine is Ubuntu 10.04 64 bit
gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.