summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2005-08-12 10:13:27 +0000
committerSimon Josefsson <simon@josefsson.org>2005-08-12 10:13:27 +0000
commit0b705df7124444e354b96e2c44740dfc5ead7ca4 (patch)
treea1bb7b20fd321111741a07abe377e36ee77d85e5
parent13b3b327ec0b6c067335b6346bd8627ba6679056 (diff)
downloadgnutls-0b705df7124444e354b96e2c44740dfc5ead7ca4.tar.gz
Use external tcp_*.
-rw-r--r--doc/examples/ex-client2.c41
1 files changed, 2 insertions, 39 deletions
diff --git a/doc/examples/ex-client2.c b/doc/examples/ex-client2.c
index 50a97dbc0d..de34b63549 100644
--- a/doc/examples/ex-client2.c
+++ b/doc/examples/ex-client2.c
@@ -14,47 +14,10 @@
#define MAX_BUF 1024
#define CAFILE "ca.pem"
-#define SA struct sockaddr
#define MSG "GET / HTTP/1.0\r\n\r\n"
-/* Connects to the peer and returns a socket
- * descriptor.
- */
-int
-tcp_connect (void)
-{
- const char *PORT = "443";
- const char *SERVER = "127.0.0.1";
- int err, sd;
- struct sockaddr_in sa;
-
- /* connects to server
- */
- sd = socket (AF_INET, SOCK_STREAM, 0);
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- err = connect (sd, (SA *) & sa, sizeof (sa));
- if (err < 0)
- {
- fprintf (stderr, "Connect error\n");
- exit (1);
- }
-
- return sd;
-}
-
-/* closes the given socket descriptor.
- */
-void
-tcp_close (int sd)
-{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
-}
+extern int tcp_connect (void);
+extern void tcp_close (int sd);
int
main (void)