From c5fdeef41d50d5207c52507e17eadc1ba1e4c5f0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Oct 2001 08:59:17 +0000 Subject: introduced non-blocking connects --- lib/connect.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/connect.h (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h new file mode 100644 index 000000000..10fd46353 --- /dev/null +++ b/lib/connect.h @@ -0,0 +1,29 @@ +#ifndef __NONBLOCK_H +#define __NONBLOCK_H +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2001, Daniel Stenberg, , et al. + * + * In order to be useful for every potential user, curl and libcurl are + * dual-licensed under the MPL and the MIT/X-derivate licenses. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the MPL or the MIT/X-derivate + * licenses. You may pick one of these licenses. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + *****************************************************************************/ + +CURLcode Curl_connecthost(struct connectdata *conn, + int sockfd, /* input socket, or -1 if none */ + int *socket); +#endif -- cgit v1.2.1 From d0079d905495c841bdf2c9885837148caa438406 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Oct 2001 11:26:21 +0000 Subject: fixed the connecthost proto: added the timeout argument --- lib/connect.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 10fd46353..40df23cc3 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -1,5 +1,5 @@ -#ifndef __NONBLOCK_H -#define __NONBLOCK_H +#ifndef __CONNECT_H +#define __CONNECT_H /***************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -24,6 +24,7 @@ *****************************************************************************/ CURLcode Curl_connecthost(struct connectdata *conn, - int sockfd, /* input socket, or -1 if none */ - int *socket); + long timeout, /* milliseconds */ + int sockfd, /* input socket, or -1 if none */ + int *socket); /* not set if error is returned */ #endif -- cgit v1.2.1 From 6918427faefa32212423cd8eb3db789d84264929 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Oct 2001 22:32:37 +0000 Subject: conn->hp is now conn->hostaddr changed the Curl_connethost() proto again --- lib/connect.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 40df23cc3..a0e3f068d 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -25,6 +25,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, long timeout, /* milliseconds */ + Curl_addrinfo *host, /* connect to this */ + long port, /* connect to this port number */ int sockfd, /* input socket, or -1 if none */ int *socket); /* not set if error is returned */ #endif -- cgit v1.2.1 From 51ca5fcbe0745cc4e245ffb69b339d1987be3b88 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Oct 2001 09:40:06 +0000 Subject: major connecting updates --- lib/connect.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index a0e3f068d..1b7319d1e 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -24,9 +24,9 @@ *****************************************************************************/ CURLcode Curl_connecthost(struct connectdata *conn, - long timeout, /* milliseconds */ Curl_addrinfo *host, /* connect to this */ long port, /* connect to this port number */ - int sockfd, /* input socket, or -1 if none */ - int *socket); /* not set if error is returned */ + int *socket, /* not set if error is returned */ + Curl_ipconnect **addr /* the one we used */ + ); /* index we used */ #endif -- cgit v1.2.1 From fdeaae678d4ce5152045fd034f32a29da9f6c5ff Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Oct 2001 06:05:56 +0000 Subject: SM's patch applied, we should not use arguments or variables that have the same name as common functions... --- lib/connect.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 1b7319d1e..8c5fac508 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -25,8 +25,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, Curl_addrinfo *host, /* connect to this */ - long port, /* connect to this port number */ - int *socket, /* not set if error is returned */ + long port, /* connect to this port number */ + int *sockconn, /* not set if error is returned */ Curl_ipconnect **addr /* the one we used */ ); /* index we used */ #endif -- cgit v1.2.1 From b07e2a08f9a98f7261d82f3ad5931ac5bcfb05a4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 31 Oct 2001 08:44:11 +0000 Subject: nonblock => Curl_nonblock, remade the check for a live SSL connection (again) --- lib/connect.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 8c5fac508..8d36365e5 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -23,6 +23,9 @@ * $Id$ *****************************************************************************/ +int Curl_nonblock(int socket, /* operate on this */ + int nonblock /* TRUE or FALSE */); + CURLcode Curl_connecthost(struct connectdata *conn, Curl_addrinfo *host, /* connect to this */ long port, /* connect to this port number */ -- cgit v1.2.1 From d0c1f3e25ba6ca86b434bb7a5f1bc01381594788 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 19 Nov 2001 20:08:01 +0000 Subject: long port => int port, as the c source uses! (Miklos Nemeth found this) --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 8d36365e5..f8c10db06 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -28,7 +28,7 @@ int Curl_nonblock(int socket, /* operate on this */ CURLcode Curl_connecthost(struct connectdata *conn, Curl_addrinfo *host, /* connect to this */ - long port, /* connect to this port number */ + int port, /* connect to this port number */ int *sockconn, /* not set if error is returned */ Curl_ipconnect **addr /* the one we used */ ); /* index we used */ -- cgit v1.2.1 From 974f314f5785156af6983675aeb28313cc8ba2ea Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Mar 2002 07:54:55 +0000 Subject: copyright string (year) update --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index f8c10db06..f44252346 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2001, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * * In order to be useful for every potential user, curl and libcurl are * dual-licensed under the MPL and the MIT/X-derivate licenses. -- cgit v1.2.1 From cb895ec3356822df72eb91171a1cc63ad1845d93 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 12 Aug 2002 09:43:20 +0000 Subject: Initial fix to make the multi interface return control while waiting for the initial connect to "come through". This should work fine for connect and for FTP-PASV connects. Needs massive testing. --- lib/connect.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index f44252346..5a6b8e63c 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -26,10 +26,15 @@ int Curl_nonblock(int socket, /* operate on this */ int nonblock /* TRUE or FALSE */); +CURLcode Curl_is_connected(struct connectdata *conn, + int sockfd, + bool *connected); + CURLcode Curl_connecthost(struct connectdata *conn, Curl_addrinfo *host, /* connect to this */ int port, /* connect to this port number */ int *sockconn, /* not set if error is returned */ - Curl_ipconnect **addr /* the one we used */ - ); /* index we used */ + Curl_ipconnect **addr, /* the one we used */ + bool *connected /* truly connected? */ + ); #endif -- cgit v1.2.1 From ba4e69bebc8f7f32f3bc7faa1e13e7580754075b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 3 Sep 2002 11:52:59 +0000 Subject: updated source code boilerplate/header --- lib/connect.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 5a6b8e63c..ceeb9fb4e 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -1,6 +1,6 @@ #ifndef __CONNECT_H #define __CONNECT_H -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | @@ -9,19 +9,19 @@ * * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * - * In order to be useful for every potential user, curl and libcurl are - * dual-licensed under the MPL and the MIT/X-derivate licenses. - * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the MPL or the MIT/X-derivate - * licenses. You may pick one of these licenses. + * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * * $Id$ - *****************************************************************************/ + ***************************************************************************/ int Curl_nonblock(int socket, /* operate on this */ int nonblock /* TRUE or FALSE */); -- cgit v1.2.1 From 2cff2518631fc538c127c1e94c47c743e2a64661 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 5 Nov 2002 10:51:41 +0000 Subject: Curl_resolv() now returns a different struct, and it contains a reference counter so that the caller needs to decrease that counter when done with the returned data. If compiled with MALLOCDEBUG I've added some extra checking that the counter is decreased before a handle is closed etc. --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index ceeb9fb4e..fdbecec0c 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -31,7 +31,7 @@ CURLcode Curl_is_connected(struct connectdata *conn, bool *connected); CURLcode Curl_connecthost(struct connectdata *conn, - Curl_addrinfo *host, /* connect to this */ + struct Curl_dns_entry *host, /* connect to this */ int port, /* connect to this port number */ int *sockconn, /* not set if error is returned */ Curl_ipconnect **addr, /* the one we used */ -- cgit v1.2.1 From f26a338a54e04d0a6907f5d2479d8b0fa9daf297 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 16 Jan 2003 21:08:12 +0000 Subject: copyright year update in the source header --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index fdbecec0c..df3147ec0 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From eb6130baa76ad0689de5eb4a24f5717eed1baa89 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 1 May 2003 13:37:05 +0000 Subject: ourerrno became Curl_ourerrno() and is now available to all libcurl --- lib/connect.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index df3147ec0..5e40232c3 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -37,4 +37,6 @@ CURLcode Curl_connecthost(struct connectdata *conn, Curl_ipconnect **addr, /* the one we used */ bool *connected /* truly connected? */ ); + +int Curl_ourerrno(void); #endif -- cgit v1.2.1 From 65dab79ca58cd95dc8741399a6ed7b8c21c606d3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 18 Oct 2003 20:14:33 +0000 Subject: gcc -Wshadow complaints fixed --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 5e40232c3..f38fbfe1b 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -23,7 +23,7 @@ * $Id$ ***************************************************************************/ -int Curl_nonblock(int socket, /* operate on this */ +int Curl_nonblock(int sockfd, /* operate on this */ int nonblock /* TRUE or FALSE */); CURLcode Curl_is_connected(struct connectdata *conn, -- cgit v1.2.1 From 053f6c85efd0bf698f73343989474d672d0563a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Jan 2004 09:19:33 +0000 Subject: updated year in the copyright string --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index f38fbfe1b..9bbf2c0ae 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From ce5805a955c5a79d85792caad47594987f0e0b26 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Mar 2004 22:52:50 +0000 Subject: Use curl_socket_t instead of int for holding sockets. The typedefs and defines are in setup.h. --- lib/connect.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 9bbf2c0ae..bccb84387 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -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? */ ); -- cgit v1.2.1 From c39858aac0584716282dcb097ce9d972b43dbcb2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 24 Jun 2004 07:43:48 +0000 Subject: Source cleanups. The major one being that we now _always_ use a Curl_addrinfo linked list for name resolved data, even on hosts/systems with only IPv4 stacks as this simplifies a lot of code. --- lib/connect.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index bccb84387..bf46ed348 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -32,9 +32,8 @@ CURLcode Curl_is_connected(struct connectdata *conn, CURLcode Curl_connecthost(struct connectdata *conn, struct Curl_dns_entry *host, /* connect to this */ - int port, /* connect to this port number */ curl_socket_t *sockconn, /* not set if error */ - Curl_ipconnect **addr, /* the one we used */ + Curl_addrinfo **addr, /* the one we used */ bool *connected /* truly connected? */ ); -- cgit v1.2.1 From 808621ab2256ba42c4d76ab73fe32e2044d93a4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 29 Jun 2004 11:21:05 +0000 Subject: corrected the Curl_is_connected() proto --- lib/connect.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index bf46ed348..6cf6b9a42 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -1,10 +1,10 @@ #ifndef __CONNECT_H #define __CONNECT_H /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. @@ -12,7 +12,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. @@ -27,7 +27,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */ int nonblock /* TRUE or FALSE */); CURLcode Curl_is_connected(struct connectdata *conn, - curl_socket_t sockfd, + int sockindex, bool *connected); CURLcode Curl_connecthost(struct connectdata *conn, -- cgit v1.2.1 From ba40eccc903990378f91ed218ed32da60bafe5b2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 30 Jun 2004 09:22:48 +0000 Subject: make the SSL connect use the same default connect timeout define as the generic connect uses --- lib/connect.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 6cf6b9a42..d39495cfc 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -38,4 +38,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, ); int Curl_ourerrno(void); + +#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ + #endif -- cgit v1.2.1 From c4ff5eb0ca9322a6671d581e80e0c63085b21426 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 29 Jan 2005 13:07:16 +0000 Subject: conn->ip_addr MUST NOT be used on re-used connections --- lib/connect.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index d39495cfc..50a9e3464 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,6 +39,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, int Curl_ourerrno(void); +CURLcode Curl_store_ip_addr(struct connectdata *conn); + #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ #endif -- cgit v1.2.1 From e85e30546c89e17b6fb0cf383de25b7ed7f3bf3d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 May 2006 22:39:47 +0000 Subject: Roland Blom filed bug report #1481217 (http://curl.haxx.se/bug/view.cgi?id=1481217), with follow-ups by Michele Bini and David Byron. libcurl previously wrongly used GetLastError() on windows to get error details after socket-related function calls, when it really should use WSAGetLastError() instead. When changing to this, the former function Curl_ourerrno() is now instead called Curl_sockerrno() as it is necessary to only use it to get errno from socket-related functions as otherwise it won't work as intended on Windows. --- lib/connect.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 50a9e3464..0f593817f 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,7 +37,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, bool *connected /* truly connected? */ ); -int Curl_ourerrno(void); +int Curl_sockerrno(void); CURLcode Curl_store_ip_addr(struct connectdata *conn); -- cgit v1.2.1 From c4ad533300b5771b8b4885c51c3b0d3e0d59ef5c Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Fri, 21 Jul 2006 06:50:39 +0000 Subject: Constify some arguments in Curl_connecthost() and singleipconnect(). --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 0f593817f..599572b27 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -31,7 +31,7 @@ CURLcode Curl_is_connected(struct connectdata *conn, bool *connected); CURLcode Curl_connecthost(struct connectdata *conn, - struct Curl_dns_entry *host, /* connect to this */ + const struct Curl_dns_entry *host, /* connect to this */ curl_socket_t *sockconn, /* not set if error */ Curl_addrinfo **addr, /* the one we used */ bool *connected /* truly connected? */ -- cgit v1.2.1 From a1d598399146984c99baa46db148e87c75261033 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 16 Feb 2007 18:19:35 +0000 Subject: use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling --- lib/connect.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 599572b27..3bfe722ea 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,8 +37,6 @@ CURLcode Curl_connecthost(struct connectdata *conn, bool *connected /* truly connected? */ ); -int Curl_sockerrno(void); - CURLcode Curl_store_ip_addr(struct connectdata *conn); #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ -- cgit v1.2.1 From 1b701c746f66b8fd5bf3017c36254dbde8456df2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 7 Feb 2008 22:25:04 +0000 Subject: - Refactored a lot of timeout code into a few functions in an attempt to make them all use the same (hopefully correct) logic to make it less error-prone and easier to introduce library-wide where it should be used. --- lib/connect.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 3bfe722ea..78c0191ba 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,14 +31,20 @@ CURLcode Curl_is_connected(struct connectdata *conn, bool *connected); CURLcode Curl_connecthost(struct connectdata *conn, - const struct Curl_dns_entry *host, /* connect to this */ + const struct Curl_dns_entry *host, /* connect to + this */ curl_socket_t *sockconn, /* not set if error */ Curl_addrinfo **addr, /* the one we used */ - bool *connected /* truly connected? */ - ); + bool *connected); /* truly connected? */ CURLcode Curl_store_ip_addr(struct connectdata *conn); +/* generic function that returns how much time there's left to run, according + to the timeouts set */ +long Curl_timeleft(struct connectdata *conn, + struct timeval *nowp, + bool duringconnect); + #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ #endif -- cgit v1.2.1 From 514592b89207e83d13b5a4e79bc247aa6f74c4b7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 12 May 2008 21:43:24 +0000 Subject: - Introducing curl_easy_send() and curl_easy_recv(). They can be used to send and receive data over a connection previously setup with curl_easy_perform() and its CURLOPT_CONNECT_ONLY option. The sendrecv.c example was added to show how they can be used. --- lib/connect.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 78c0191ba..8e55cc941 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -47,4 +47,13 @@ long Curl_timeleft(struct connectdata *conn, #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ +/* + * Used to extract socket and connectdata struct for the most recent + * transfer on the given SessionHandle. + * + * The socket 'long' will be -1 in case of failure! + */ +CURLcode Curl_getconnectinfo(struct SessionHandle *data, + long *param_longp, + struct connectdata **connp); #endif -- cgit v1.2.1 From d0b8b5a1990a31f37fcab925cb8b59bee958d41d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 3 Nov 2008 16:24:56 +0000 Subject: - Bug #2218480 (http://curl.haxx.se/bug/view.cgi?id=2218480) pointed out a problem with my CURLINFO_PRIMARY_IP fix from October 7th that caused a NULL pointer read. I also took the opportunity to clean up this logic (storing of the connection's IP address) somewhat as we had it stored in two different places and ways previously and they are now unified. --- lib/connect.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 8e55cc941..38ed4125b 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -37,8 +37,6 @@ CURLcode Curl_connecthost(struct connectdata *conn, Curl_addrinfo **addr, /* the one we used */ bool *connected); /* truly connected? */ -CURLcode Curl_store_ip_addr(struct connectdata *conn); - /* generic function that returns how much time there's left to run, according to the timeouts set */ long Curl_timeleft(struct connectdata *conn, -- cgit v1.2.1 From 9c788a529beb63e95de5be013bb4b0f26f8456a0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 7 May 2009 20:00:44 +0000 Subject: - Made the SO_SNDBUF setting for the data connection socket for ftp uploads as well. See change 28 Apr 2009. --- lib/connect.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 38ed4125b..ae47c2174 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -54,4 +54,20 @@ long Curl_timeleft(struct connectdata *conn, CURLcode Curl_getconnectinfo(struct SessionHandle *data, long *param_longp, struct connectdata **connp); + +#ifdef WIN32 +/* When you run a program that uses the Windows Sockets API, you may + experience slow performance when you copy data to a TCP server. + + http://support.microsoft.com/kb/823764 + + Work-around: Make the Socket Send Buffer Size Larger Than the Program Send + Buffer Size + +*/ +void Curl_sndbufset(curl_socket_t sockfd); +#else +#define Curl_sndbufset(y) +#endif + #endif -- cgit v1.2.1 From d709cb2ae37c9d9512fe3a9724dd95b0fe49d108 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 9 Jul 2009 21:47:24 +0000 Subject: - Eric Wong introduced curlx_nonblock() that the curl tool now (re-)uses for setting a file descriptor non-blocking. Used by the functionality Eric himself brough on June 15th. --- lib/connect.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index ae47c2174..e8261776a 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -23,8 +23,7 @@ * $Id$ ***************************************************************************/ -int Curl_nonblock(curl_socket_t sockfd, /* operate on this */ - int nonblock /* TRUE or FALSE */); +#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */ CURLcode Curl_is_connected(struct connectdata *conn, int sockindex, -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/connect.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index e8261776a..36ea4f639 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -20,7 +20,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */ -- cgit v1.2.1 From 8098d9417c649272b9d6d2ad76abbde7dfbfcad1 Mon Sep 17 00:00:00 2001 From: Frank Meier Date: Sat, 5 Jun 2010 00:29:09 +0200 Subject: getinfo: added *_PRIMARY_PORT, *_LOCAL_IP and *_LOCAL_PORT --- lib/connect.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 36ea4f639..b365f7d0c 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -68,4 +68,6 @@ void Curl_sndbufset(curl_socket_t sockfd); #define Curl_sndbufset(y) #endif +void Curl_updateconninfo(curl_socket_t sockfd, struct PureInfo* info); + #endif -- cgit v1.2.1 From f737e94164fd33cbb03a559ff51d4b4db59902ea Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 7 Jun 2010 16:53:31 +0200 Subject: Curl_updateconninfo() error handling fix --- lib/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index b365f7d0c..57b1c2f2d 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -68,6 +68,6 @@ void Curl_sndbufset(curl_socket_t sockfd); #define Curl_sndbufset(y) #endif -void Curl_updateconninfo(curl_socket_t sockfd, struct PureInfo* info); +void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); #endif -- cgit v1.2.1 From c6fa1952a14ba2fa14f4a3483f1f573560ef3133 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 6 Sep 2010 00:02:54 +0200 Subject: portabilty: use proper variable type to hold sockets Curl_getconnectinfo() is changed to return a proper curl_socket_t for the last socket so that it'll work more portably (and cause less compiler warnings). --- lib/connect.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 57b1c2f2d..2c6b10a38 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -47,11 +47,10 @@ long Curl_timeleft(struct connectdata *conn, * Used to extract socket and connectdata struct for the most recent * transfer on the given SessionHandle. * - * The socket 'long' will be -1 in case of failure! + * The returned socket will be CURL_SOCKET_BAD in case of failure! */ -CURLcode Curl_getconnectinfo(struct SessionHandle *data, - long *param_longp, - struct connectdata **connp); +curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, + struct connectdata **connp); #ifdef WIN32 /* When you run a program that uses the Windows Sockets API, you may -- cgit v1.2.1 From 11cddb68e0ff73c8297b85e51bebaf6f968a8d62 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 30 Nov 2010 22:14:37 +0100 Subject: fix getinfo CURLINFO_LOCAL* for reused connections (take 2) --- lib/connect.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 2c6b10a38..6cc403d9f 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -69,4 +69,6 @@ void Curl_sndbufset(curl_socket_t sockfd); void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); +void Curl_persistconninfo(struct connectdata *conn); + #endif -- cgit v1.2.1 From adb49ad8bb280b586b387ba930c0681afee03923 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 4 Jan 2011 23:07:58 +0100 Subject: Curl_timeleft: s/conn/data in first argument As the function doesn't really use the connectdata struct but only the SessionHanadle struct I modified what argument it wants. --- lib/connect.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 6cc403d9f..0720085c2 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,7 +37,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* generic function that returns how much time there's left to run, according to the timeouts set */ -long Curl_timeleft(struct connectdata *conn, +long Curl_timeleft(struct SessionHandle *data, struct timeval *nowp, bool duringconnect); -- cgit v1.2.1 From b5d170b55110bacc61a4aa8bf99df1afc303c5dc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 16 May 2011 23:46:43 +0200 Subject: CLOSESOCKETFUNCTION: added Introduced the initial setup to allow closesocket callbacks by making sure sclose() is only ever called from one place in the libcurl source and still run all test cases fine. --- lib/connect.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 0720085c2..3df9d970e 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -68,7 +68,6 @@ void Curl_sndbufset(curl_socket_t sockfd); #endif void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); - void Curl_persistconninfo(struct connectdata *conn); - +int Curl_closesocket(struct connectdata *conn, curl_socket_t sock); #endif -- cgit v1.2.1 From 2ccffbb37e9f453b13c8ded409eacf15d46daf48 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 7 Aug 2011 08:45:57 +0200 Subject: BSD-style lwIP TCP/IP stack support - followup lwIP library initialization. --- lib/connect.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 3df9d970e..299233d4f 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -1,5 +1,5 @@ -#ifndef __CONNECT_H -#define __CONNECT_H +#ifndef HEADER_CURL_CONNECT_H +#define HEADER_CURL_CONNECT_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -52,7 +52,7 @@ long Curl_timeleft(struct SessionHandle *data, curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, struct connectdata **connp); -#ifdef WIN32 +#ifdef USE_WINSOCK /* When you run a program that uses the Windows Sockets API, you may experience slow performance when you copy data to a TCP server. @@ -70,4 +70,5 @@ void Curl_sndbufset(curl_socket_t sockfd); void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); void Curl_persistconninfo(struct connectdata *conn); int Curl_closesocket(struct connectdata *conn, curl_socket_t sock); -#endif + +#endif /* HEADER_CURL_CONNECT_H */ -- cgit v1.2.1 From 6b75d2c2df7209919a70a29a4479625b62fb3c28 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Sep 2011 16:06:10 +0200 Subject: fix a bunch of MSVC compiler warnings --- lib/connect.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 299233d4f..052549368 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -21,6 +21,7 @@ * KIND, either express or implied. * ***************************************************************************/ +#include "setup.h" #include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */ @@ -64,7 +65,7 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, */ void Curl_sndbufset(curl_socket_t sockfd); #else -#define Curl_sndbufset(y) +#define Curl_sndbufset(y) Curl_nop_stmt #endif void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); -- cgit v1.2.1 From 9109cdec11ee5a19f132fd7bdf2e9ceefea4de41 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Dec 2011 10:58:38 +0100 Subject: Curl_socket: internal replacement for socket() Moved out into a separate function to work as a "generic" socket() replacement. --- lib/connect.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 052549368..f84361f2e 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -24,6 +24,7 @@ #include "setup.h" #include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */ +#include "sockaddr.h" CURLcode Curl_is_connected(struct connectdata *conn, int sockindex, @@ -72,4 +73,35 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); void Curl_persistconninfo(struct connectdata *conn); int Curl_closesocket(struct connectdata *conn, curl_socket_t sock); +/* + * The Curl_sockaddr_ex structure is basically libcurl's external API + * curl_sockaddr structure with enough space available to directly hold any + * protocol-specific address structures. The variable declared here will be + * used to pass / receive data to/from the fopensocket callback if this has + * been set, before that, it is initialized from parameters. + */ +struct Curl_sockaddr_ex { + int family; + int socktype; + int protocol; + unsigned int addrlen; + union { + struct sockaddr addr; + struct Curl_sockaddr_storage buff; + } _sa_ex_u; +}; +#define sa_addr _sa_ex_u.addr + +/* + * Create a socket based on info from 'conn' and 'ai'. + * + * Fill in 'addr' and 'sockfd' accordingly if OK is returned. If the open + * socket callback is set, used that! + * + */ +CURLcode Curl_socket(struct connectdata *conn, + const Curl_addrinfo *ai, + struct Curl_sockaddr_ex *addr, + curl_socket_t *sockfd); + #endif /* HEADER_CURL_CONNECT_H */ -- cgit v1.2.1 From c834213ad52c52431e9ca597862dc81839cabe84 Mon Sep 17 00:00:00 2001 From: Gokhan Sengun Date: Mon, 19 Dec 2011 14:35:20 +0100 Subject: FTP: perform active connections non-blocking 1- Two new error codes are introduced. CURLE_FTP_ACCEPT_FAILED to be set whenever ACCEPTing fails because of FTP server connected. CURLE_FTP_ACCEPT_TIMEOUT to be set whenever ACCEPTing timeouts. Neither of these errors are considered fatal and control connection remains OK because it could just be a firewall blocking server to connect to the client. 2- One new setopt option was introduced. CURLOPT_ACCEPTTIMEOUT_MS It sets the maximum amount of time FTP client is going to wait for a server to connect. Internal default accept timeout is 60 seconds. --- lib/connect.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index f84361f2e..4e905bdf5 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -43,7 +43,12 @@ long Curl_timeleft(struct SessionHandle *data, struct timeval *nowp, bool duringconnect); +/* function that returns how much time there's left to wait for incoming + server connect */ +long Curl_timeleft_accept(struct SessionHandle *data); + #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ +#define DEFAULT_ACCEPT_TIMEOUT 60000 /* milliseconds == one minute */ /* * Used to extract socket and connectdata struct for the most recent -- cgit v1.2.1 From 130fac6c16c4fb8a7eeec116adc479aad1e3273d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 Dec 2011 20:55:54 +0100 Subject: timeleft_accept: ack global timeout, moved to ftp.c First off the timeout for accepting a server connect back must of course respect a global timeout. Then the timeleft function is only used by ftp code so it was moved to ftp.c and made static. --- lib/connect.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lib/connect.h') diff --git a/lib/connect.h b/lib/connect.h index 4e905bdf5..f84361f2e 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -43,12 +43,7 @@ long Curl_timeleft(struct SessionHandle *data, struct timeval *nowp, bool duringconnect); -/* function that returns how much time there's left to wait for incoming - server connect */ -long Curl_timeleft_accept(struct SessionHandle *data); - #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ -#define DEFAULT_ACCEPT_TIMEOUT 60000 /* milliseconds == one minute */ /* * Used to extract socket and connectdata struct for the most recent -- cgit v1.2.1