aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-31 07:01:06 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-31 07:01:06 +0000
commit34548a4d7bf2368ef5dcfe69ec10c1ea5305af5e (patch)
treef458462f57689ddb65272648b03a6551efda4616 /socket.c
parent0318e71e86068a7c1789cb6e1a54a29df112d263 (diff)
downloadfetchmail-34548a4d7bf2368ef5dcfe69ec10c1ea5305af5e.tar.gz
fetchmail-34548a4d7bf2368ef5dcfe69ec10c1ea5305af5e.tar.bz2
fetchmail-34548a4d7bf2368ef5dcfe69ec10c1ea5305af5e.zip
STEP 6: Socket() returns file pointer.
svn path=/trunk/; revision=449
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/socket.c b/socket.c
index ae38cd32..f5b73b98 100644
--- a/socket.c
+++ b/socket.c
@@ -4,11 +4,8 @@
* These were designed and coded by Carl Harris <ceharris@mal.com>
* and are essentially unchanged from the ancestral popclient.
*
- * Actually, this library shouldn't exist. We ought to be using
- * stdio to buffer the socket descriptors. If that worked, we
- * could have separate buffers for the mailserver and SMTP sockets,
- * and we'd be able to handle responses longer than the socket
- * atomic read size.
+ * The file pointer arguments are currently misleading -- there
+ * is only one shared internal buffer for all sockets.
*
* For license terms, see the file COPYING in this directory.
*/
@@ -45,7 +42,7 @@
#define INTERNAL_BUFSIZE 2048
-int Socket(host, clientPort)
+FILE *Socket(host, clientPort)
char *host;
int clientPort;
{
@@ -64,17 +61,17 @@ int clientPort;
{
hp = gethostbyname(host);
if (hp == NULL)
- return -1;
+ return (FILE *)NULL;
memcpy(&ad.sin_addr, hp->h_addr, hp->h_length);
}
ad.sin_port = htons(clientPort);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
- return sock;
+ return (FILE *)NULL;
if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
- return -1;
- return sock;
+ return (FILE *)NULL;
+ return fdopen(sock, "r+");
}
int SockPuts(buf, sockfp)