Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
From: "ja" <rodercat@giga.net.tw>
Subject: Who can help me?
Date: Mon, 16 Apr 2001 20:31:30 +0800	[thread overview]
Message-ID: <9beonk$16dd$1@news1.giga.net.tw> (raw)


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






             reply	other threads:[~2001-04-16 12:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-16 12:31 ja [this message]
2001-04-19  5:21 ` Who can help me? Aneesh Kumar K.V
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