Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
* Who can help me?
@ 2001-04-16 12:31 ja
  2001-04-19  5:21 ` Aneesh Kumar K.V
  0 siblings, 1 reply; 2+ messages in thread
From: ja @ 2001-04-16 12:31 UTC (permalink / 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






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-19  5:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-16 12:31 Who can help me? ja
2001-04-19  5:21 ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox