From: "Aneesh Kumar K.V" <aneesh.kumar@digital.com>
Subject: Re: Who can help me?
Date: Thu, 19 Apr 2001 10:51:52 +0530 [thread overview]
Message-ID: <3ADE75F0.1F75B49@digital.com> (raw)
In-Reply-To: 9beonk$16dd$1@news1.giga.net.tw
Hi ,
Try
including header in the order given in the manual . time , types , unistd.h
.
and for try
if (connect (Socket, ( const srtruct sockaddr *)ServerAddr, sizeof (struct
sockaddr_in)) == ERROR)
{
-aneesh
ja wrote:
> I face a problem about compile.
>
> %cc -o AppTest AppTest.c
> AppTest.c: In function 'Attempt Connection':
> AppTest.c:253: in compatible type for argument 2 of 'connect'
> AppTest.c: In function 'GetReturnStatus':
> AppTest.c:storage size of 'readFds' isn't known.
>
> Do you know what's wrong?
> Below is my program.
>
> #include <errno.h>
> #include <sys/errno.h>
> #include <sys/param.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <sys/time.h>
> #include <signal.h>
> #include <stdio.h>
> #include <netdb.h>
> #include <fcntl.h>
> #include <unistd.h>
>
> /* include files needed for "herror ()" call */
> #include <sys/types.h>
> #include <netinet/in.h>
> #include <arpa/nameser.h>
> #include <resolv.h>
>
> int AttemptConnection (ConnectionStatus)
> int *ConnectionStatus;
> {
> int Socket, I;
> struct sockaddr_in ServerAddr;
>
> Socket = stream_socket_info.Socket;
> ServerAddr = stream_socket_info.Addr;
>
> //AppTest.c:253: in compatible type for argument 2 of 'connect'
> // compile tell me ServerAddr have something wrong . why???
> // How to modify ?
> if (connect (Socket, ServerAddr, sizeof (struct sockaddr_in)) == ERROR)
> {
> if (errno == ECONNREFUSED)
> {
> perror ("INFO - Attempting connection to server ");
> close (Socket);
> if (CreateStreamSocket(I) == ERROR) return(ERROR);
> }
> else
> {
> perror ("FATAL ERROR - Attempting connection to server ");
> return (ERROR);
> }
> }
> else
> {
>
> printf ("Successful connection to %s\n", stream_socket_info.HostName);
>
> *ConnectionStatus = CONNECTED;
> return (NO_ERROR);
> }
> *ConnectionStatus = NOT_CONNECTED;
> return (NO_ERROR);
> }
>
> int GetReturnStatus ()
> {
> int BytesRead;
> int selectCount;
> //AppTest.c:storage size of 'readFds' isn't known.
> //How to modify?
> struct fd_set readFds;
> struct timeval timeLimit;
>
> timeLimit.tv_sec = TIME_OUT;
> timeLimit.tv_usec = 0;
>
> FD_ZERO (&readFds);
>
> FD_SET (stream_socket_info.Socket, &readFds);
>
> printf("WAITING FOR RESPONSE.....\n");
> selectCount = select (FD_SETSIZE, &readFds, NULL,NULL, &timeLimit);
>
> if (selectCount == ERROR)
> {
> printf ("FATAL ERROR - select failed in GetReturnStatus.\n");
> return (ERROR);
> }
>
> if (selectCount == 0)
> {
> printf ("FATAL ERROR - Time out occured in GetReturnStatus.\n");
> return (ERROR);
> }
>
> if ((BytesRead =
> read (stream_socket_info.Socket, &control_message, BUFLEN)) ==
> ERROR)
> {
> perror ("FATAL ERROR - GetReturnStatus (read).\n");
> return (ERROR);
> }
>
> if (BytesRead < BUFLEN)
> {
> printf ("FATAL ERROR - Read from socket incomplete!!! \n");
> return (ERROR);
> }
>
> printf ("%s for %s \n", control_message.Buffer1, WscStationId);
>
> }
>
> Thank you!
>
> rodercat@giga.net.tw
prev parent reply other threads:[~2001-04-19 5:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-16 12:31 Who can help me? ja
2001-04-19 5:21 ` Aneesh Kumar K.V [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox