Commit ce5805a9 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Use curl_socket_t instead of int for holding sockets. The typedefs and

defines are in setup.h.
parent dad0715d
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@
#include "memdebug.h"
#endif

static bool verifyconnect(int sockfd);
static bool verifyconnect(curl_socket_t sockfd);

int Curl_ourerrno(void)
{
@@ -104,7 +104,7 @@ int Curl_ourerrno(void)
 *  Set the socket to either blocking or non-blocking mode.
 */

int Curl_nonblock(int sockfd,    /* operate on this */
int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                  int nonblock   /* TRUE or FALSE */)
{
#undef SETBLOCK
@@ -168,7 +168,7 @@ int Curl_nonblock(int sockfd, /* operate on this */
 * 2    select() returned with an error condition
 */
static
int waitconnect(int sockfd, /* socket */
int waitconnect(curl_socket_t sockfd, /* socket */
                long timeout_msec)
{
  fd_set fd;
@@ -212,7 +212,7 @@ int waitconnect(int sockfd, /* socket */
}

static CURLcode bindlocal(struct connectdata *conn,
                          int sockfd)
                          curl_socket_t sockfd)
{
#ifdef HAVE_INET_NTOA
  bool bindworked = FALSE;
@@ -401,7 +401,7 @@ static CURLcode bindlocal(struct connectdata *conn,
/*
 * verifyconnect() returns TRUE if the connect really has happened.
 */
static bool verifyconnect(int sockfd)
static bool verifyconnect(curl_socket_t sockfd)
{
#if defined(SO_ERROR) && !defined(WIN32)
  int err = 0;
@@ -427,7 +427,7 @@ static bool verifyconnect(int sockfd)
 */

CURLcode Curl_is_connected(struct connectdata *conn,
                           int sockfd,
                           curl_socket_t sockfd,
                           bool *connected)
{
  int rc;
@@ -505,13 +505,13 @@ CURLcode Curl_is_connected(struct connectdata *conn,
CURLcode Curl_connecthost(struct connectdata *conn,  /* context */
                          struct Curl_dns_entry *remotehost, /* use this one */
                          int port,                  /* connect to this */
                          int *sockconn,             /* the connected socket */
                          curl_socket_t *sockconn,   /* the connected socket */
                          Curl_ipconnect **addr,     /* the one we used */
                          bool *connected)           /* really connected? */
{
  struct SessionHandle *data = conn->data;
  int rc;
  int sockfd=-1;
  curl_socket_t sockfd= CURL_SOCKET_BAD;
  int aliasindex=0;
  char *hostname;

@@ -587,7 +587,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */

    /* create an IPv4 TCP socket */
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if(-1 == sockfd) {
    if(CURL_SOCKET_BAD == sockfd) {
      failf(data, "couldn't create socket");
      return CURLE_COULDNT_CONNECT; /* big time error */
    }
+3 −3
Original line number Diff line number Diff line
@@ -23,17 +23,17 @@
 * $Id$
 ***************************************************************************/

int Curl_nonblock(int sockfd,    /* operate on this */
int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                  int nonblock   /* TRUE or FALSE */);

CURLcode Curl_is_connected(struct connectdata *conn,
                           int sockfd,
                           curl_socket_t sockfd,
                           bool *connected);

CURLcode Curl_connecthost(struct connectdata *conn,
                          struct Curl_dns_entry *host, /* connect to this */
                          int port,       /* connect to this port number */
                          int *sockconn,  /* not set if error is returned */
                          curl_socket_t *sockconn, /* not set if error */
                          Curl_ipconnect **addr, /* the one we used */
                          bool *connected /* truly connected? */
                          );
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ CURLcode Curl_dict(struct connectdata *conn)
                          by RFC 2229 */
  CURLcode result=CURLE_OK;
  struct SessionHandle *data=conn->data;
  int sockfd = conn->sock[FIRSTSOCKET];
  curl_socket_t sockfd = conn->sock[FIRSTSOCKET];

  char *path = conn->path;
  curl_off_t *bytecount = &conn->bytecount;
+9 −9
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
  fd_set rdset;
  struct timeval dt;
  struct SessionHandle *data = conn->data;
  int sock = conn->sock[SECONDARYSOCKET];
  curl_socket_t sock = conn->sock[SECONDARYSOCKET];
  struct timeval now = Curl_tvnow();
  long timespent = Curl_tvdiff(Curl_tvnow(), now)/1000;
  long timeout = data->set.connecttimeout?data->set.connecttimeout:
@@ -211,7 +211,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
   * Alas, read as much as possible, split up into lines, use the ending
   * line in a response or continue reading.  */

  int sockfd = conn->sock[FIRSTSOCKET];
  curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  int perline; /* count bytes per line */
  bool keepon=TRUE;
  ssize_t gotbytes;
@@ -1103,7 +1103,7 @@ static
CURLcode ftp_use_port(struct connectdata *conn)
{
  struct SessionHandle *data=conn->data;
  int portsock=-1;
  curl_socket_t portsock= CURL_SOCKET_BAD;
  ssize_t nread;
  int ftpcode; /* receive FTP response codes in this */
  CURLcode result;
@@ -1166,7 +1166,7 @@ CURLcode ftp_use_port(struct connectdata *conn)
    return CURLE_FTP_PORT_FAILED;
  }
  
  portsock = -1;
  portsock = CURL_SOCKET_BAD;
  for (ai = res; ai; ai = ai->ai_next) {
    /*
     * Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
@@ -1175,25 +1175,25 @@ CURLcode ftp_use_port(struct connectdata *conn)
      ai->ai_socktype = hints.ai_socktype;

    portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
    if (portsock < 0)
    if (portsock == CURL_SOCKET_BAD)
      continue;

    if (bind(portsock, ai->ai_addr, ai->ai_addrlen) < 0) {
      sclose(portsock);
      portsock = -1;
      portsock = CURL_SOCKET_BAD;
      continue;
    }
      
    if (listen(portsock, 1) < 0) {
      sclose(portsock);
      portsock = -1;
      portsock = CURL_SOCKET_BAD;
      continue;
    }
    
    break;
  }
  freeaddrinfo(res);
  if (portsock < 0) {
  if (portsock == CURL_SOCKET_BAD) {
    failf(data, "%s", strerror(errno));
    return CURLE_FTP_PORT_FAILED;
  }
@@ -1378,7 +1378,7 @@ CURLcode ftp_use_port(struct connectdata *conn)
    Curl_resolv_unlock(data, h);

  if ( h || sa_filled_in) {
    if( (portsock = socket(AF_INET, SOCK_STREAM, 0)) >= 0 ) {
    if( (portsock = socket(AF_INET, SOCK_STREAM, 0)) != CURL_SOCKET_BAD ) {
      int size;
      
      /* we set the secondary socket variable to this for now, it
+1 −1
Original line number Diff line number Diff line
@@ -531,7 +531,7 @@ CURLcode add_buffer_send(send_buffer *in,
  size_t size;
  struct HTTP *http = conn->proto.http;
  size_t sendsize;
  int sockfd = conn->sock[FIRSTSOCKET];
  curl_socket_t sockfd = conn->sock[FIRSTSOCKET];

  /* The looping below is required since we use non-blocking sockets, but due
     to the circumstances we will just loop and try again and again etc */
Loading