diff -ru ../../curl-7.18.1/docs/examples/Makefile.inc ./docs/examples/Makefile.inc
--- ../../curl-7.18.1/docs/examples/Makefile.inc	2008-02-18 18:32:34.000000000 +0300
+++ ./docs/examples/Makefile.inc	2008-05-05 11:52:24.000000000 +0400
@@ -4,7 +4,8 @@
   getinfo getinmemory http-post httpput \
   https multi-app multi-debugcallback multi-double \
   multi-post multi-single persistant post-callback \
-  postit2 sepheaders simple simplepost simplessl
+  postit2 sepheaders simple simplepost simplessl \
+  sendrecv
 
 # These examples require external dependencies that may not be commonly
 # available on POSIX systems, so don't bother attempting to compile them here.
diff -ru ../../curl-7.18.1/include/curl/curl.h ./include/curl/curl.h
--- ../../curl-7.18.1/include/curl/curl.h	2008-03-30 13:00:51.000000000 +0400
+++ ./include/curl/curl.h	2008-05-05 10:49:51.000000000 +0400
@@ -441,6 +441,8 @@
 
   CURLE_SSL_SHUTDOWN_FAILED,     /* 80 - Failed to shut down the SSL
                                     connection */
+  CURLE_AGAIN,                   /* 81 - socket is not ready for send/recv,
+                                    wait till it's ready and try again */
   CURL_LAST /* never use! */
 } CURLcode;
 
diff -ru ../../curl-7.18.1/include/curl/easy.h ./include/curl/easy.h
--- ../../curl-7.18.1/include/curl/easy.h	2004-11-09 17:02:58.000000000 +0300
+++ ./include/curl/easy.h	2008-04-30 10:32:38.000000000 +0400
@@ -74,6 +74,29 @@
  */
 CURL_EXTERN void curl_easy_reset(CURL *curl);
 
+/*
+ * NAME curl_easy_recv()
+ *
+ * DESCRIPTION
+ *
+ * Receives data from the connected socket. Use after successful curl_easy_perform()
+ * with CURLOPT_CONNECT_ONLY option.
+ */
+CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
+    size_t *n);
+
+/*
+ * NAME curl_easy_send()
+ *
+ * DESCRIPTION
+ *
+ * Sends data over the connected socket. Use after successful curl_easy_perform()
+ * with CURLOPT_CONNECT_ONLY option.
+ */
+CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, size_t buflen,
+    size_t *n);
+
+
 #ifdef  __cplusplus
 }
 #endif
diff -ru ../../curl-7.18.1/lib/easy.c ./lib/easy.c
--- ../../curl-7.18.1/lib/easy.c	2008-03-20 14:09:59.000000000 +0300
+++ ./lib/easy.c	2008-05-05 11:17:17.000000000 +0400
@@ -1046,3 +1046,102 @@
 }
 
 #endif /* CURL_DOES_CONVERSIONS */
+
+/*
+ * Receives data from the connected socket. Use after successful
+ * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
+ * Returns CURLE_OK on success, error code on error.
+ */
+CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n)
+{
+  curl_socket_t sfd;
+  CURLcode ret;
+  int ret1;
+  ssize_t n1;
+  struct connectdata *c = NULL;
+  struct SessionHandle *data = (struct SessionHandle *)curl;
+  if(data == NULL)
+    return CURLE_RECV_ERROR;
+  /* only allow recv to be called on handles with CURLOPT_CONNECT_ONLY */
+  if(! data->set.connect_only)
+    return CURLE_RECV_ERROR;
+
+  /* Get connectdata for the handle. Shamelessly stolen from getopt.c */
+  if((data->state.lastconnect != -1) &&
+    (data->state.connc->connects[data->state.lastconnect] != NULL))
+      c = data->state.connc->connects[data->state.lastconnect];
+
+  if(c == NULL)
+    return CURLE_RECV_ERROR;
+
+  ret = Curl_getinfo(data, CURLINFO_LASTSOCKET, &sfd);
+
+  if(ret != CURLE_OK)
+    return ret;
+
+  if(sfd == -1)
+    return CURLE_RECV_ERROR;
+
+  *n = 0;
+  ret1 = Curl_read(c, sfd, buffer, buflen, &n1);
+
+  if(ret1 == -1)
+    return CURLE_AGAIN;
+
+  if(n1 == -1)
+    return CURLE_RECV_ERROR;
+
+  *n = (size_t)n1;
+
+  return CURLE_OK;							
+}
+
+/*
+ * Sends data over the connected socket. Use after successful
+ * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
+ */
+CURLcode curl_easy_send(CURL *curl, const void *buffer, size_t buflen,
+                        size_t *n)
+{
+  curl_socket_t sfd;
+  CURLcode ret;
+  ssize_t n1;
+  struct connectdata *c = NULL;
+  struct SessionHandle *data = (struct SessionHandle *)curl;
+  if(data == NULL)
+    return CURLE_SEND_ERROR;
+  /* only allow send to be called on handles with CURLOPT_CONNECT_ONLY */
+  if(! data->set.connect_only)
+    return CURLE_SEND_ERROR;
+
+  /* Get connectdata for the handle. Shamelessly stolen from getopt.c */
+  if((data->state.lastconnect != -1) &&
+    (data->state.connc->connects[data->state.lastconnect] != NULL))
+      c = data->state.connc->connects[data->state.lastconnect];
+
+  if(c == NULL)
+    return CURLE_SEND_ERROR;
+
+  ret = Curl_getinfo(data, CURLINFO_LASTSOCKET, &sfd);
+
+  if(ret != CURLE_OK)
+    return ret;
+
+  if(sfd == -1)
+    return CURLE_SEND_ERROR;
+
+  *n = 0;
+  ret = Curl_write(c, sfd, buffer, buflen, &n1);
+
+  if(n1 == -1)
+    return CURLE_SEND_ERROR;
+
+  /* A pitiful attempt to detect EAGAIN */
+  if((CURLE_OK == ret) && (0 == n1))
+    return CURLE_AGAIN;
+
+  *n = (size_t)n1;
+
+  return ret;
+}
+
diff -ru ../../curl-7.18.1/lib/strerror.c ./lib/strerror.c
--- ../../curl-7.18.1/lib/strerror.c	2007-11-07 12:21:36.000000000 +0300
+++ ./lib/strerror.c	2008-05-05 10:51:54.000000000 +0400
@@ -261,6 +261,9 @@
   case CURLE_SSH:
     return "Error in the SSH layer";
 
+  case CURLE_AGAIN:
+    return "Socket not ready for send/recv";
+
     /* error codes not used by current libcurl */
   case CURLE_OBSOLETE4:
   case CURLE_OBSOLETE10:
