I am using WATCOM 16 bit compiler and WATT32 socket library for simple socket program that should run in 16 bit DOS system.
I am getting the below showed error please help me…
C:\DOCUME~1\Mahendra\Desktop\watt\ZIPFIL~1>wcl /l=dos client.c
Open Watcom C/C++16 Compile and Link Utility Version 1.8
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See openwatcom.org/ for details.
wcc CLIENT.C
DOS/4GW Protected Mode Run-time Version 1.97
Copyright (c) Rational Systems, Inc. 1990-1994
Open Watcom C16 Optimizing Compiler Version 1.8
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See openwatcom.org/ for details.
CLIENT.C(46): Warning! W131: No prototype found for function ‘htons’
CLIENT.C(66): Warning! W131: No prototype found for function ‘close’
CLIENT.C: 69 lines, included 6431, 2 warnings, 0 errors
Code size: 208
wlink @wcl.lnk
DOS/4GW Protected Mode Run-time Version 1.97
Copyright (c) Rational Systems, Inc. 1990-1994
Open Watcom Linker Version 1.8
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See openwatcom.org/ for details.
loading object files
searching libraries
Error! E2028: gethostbyname_ is an undefined reference
Error! E2028: socket_ is an undefined reference
Error! E2028: htons_ is an undefined reference
Error! E2028: connect_ is an undefined reference
Error! E2028: recv_ is an undefined reference
creating a DOS executable
file CLIENT.obj(C:\DOCUME~1\MAHENDRA\DESKTOP\WATT\ZIPFIL~1\CLIENT.C): undefined
symbol gethostbyname_
file CLIENT.obj(C:\DOCUME~1\MAHENDRA\DESKTOP\WATT\ZIPFIL~1\CLIENT.C): undefined
symbol socket_
file CLIENT.obj(C:\DOCUME~1\MAHENDRA\DESKTOP\WATT\ZIPFIL~1\CLIENT.C): undefined
symbol htons_
file CLIENT.obj(C:\DOCUME~1\MAHENDRA\DESKTOP\WATT\ZIPFIL~1\CLIENT.C): undefined
symbol connect_
file CLIENT.obj(C:\DOCUME~1\MAHENDRA\DESKTOP\WATT\ZIPFIL~1\CLIENT.C): undefined
symbol recv_
Error: Linker returned a bad status
This simple socket code which one i m trying to compile…
/*
- client.c – a stream socket client demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define PORT 3490 /* the port client will be connecting to */
#define MAXDATASIZE 100 /* max number of bytes we can get at once */
int main (int argc, char **argv)
{
struct hostent he;
struct sockaddr_in their_addr; / connector’s address information */
int sockfd, numbytes;
char buf[MAXDATASIZE];
if (argc != 2)
{
fprintf (stderr,“usage: client hostname\n”);
return (1);
}
if ((he = gethostbyname(argv[1])) == NULL) /* get the host info */
{
perror (“gethostbyname”);
return (1);
}
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror (“socket”);
return (1);
}
their_addr.sin_family = AF_INET; /* host byte order /
their_addr.sin_port = htons(PORT); / short, network byte order */
their_addr.sin_addr = *((struct in_addr )he->h_addr);
memset (&their_addr.sin_zero,0,8); / zero the rest of the struct */
if (connect(sockfd, (struct sockaddr*)&their_addr,
sizeof(struct sockaddr)) == -1)
{
perror (“connect”);
return (1);
}
if ((numbytes = recv(sockfd, buf, MAXDATASIZE, 0)) == -1)
{
perror (“recv”);
return (1);
}
buf[numbytes] = ‘\0’;
printf (“Received: %s”,buf);
close (sockfd);
return (0);
}