From: "John T. Williams" <jowillia@vt.edu>
To: John T Williams <jtwilliams@contextweb.com>
Cc: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Re: connecting to a hoast
Date: Mon, 13 Sep 2004 02:16:45 -0500 [thread overview]
Message-ID: <1095059805.2813.0.camel@client001> (raw)
In-Reply-To: <Pine.LNX.4.61.0409121703550.2066@debian>
Ok
-------- Start Code ---------------------------------
#include <sys/socket.h> // for connection api
#include <sys/types.h> // for predefined values
#include <netdb.h> // for hostname resolution api
char* host = "ftp.domain.com¡;
int port = 25;
struct sockaddr_in passive;
struct protoent * proto;
int skt;
proto = getprotobyname("tcp")
// gets the prototype number for tcp/ip
skt = socket(PF_INET, SOCK_STREAM, proto->p_proto );
//creates a socket
passive.sin_family = AF_INET;
// IPv4 connection type
passive.sin_addr = gethostbye(host);
// resolves the hostname and returns the correct in_addr
passive.sin_port = htons(port);
// htons changes the bit order so that it is in network format
connect(skt, &passive, sizeof(passive));
// connect to host
close(skt);
// close connection
-------- End Code -----------------------------------
this code does not check for errors and will probably crash if anything
goes wrong. How ever it does show how to connect to a server.
You should read:
http://www.gnu.org/software/libc/manual/html_node/Connections.html#Connections
- John
On Sun, 2004-09-12 at 16:04, Ameer Armaly wrote:
> Hi all.
> I was wondering, where is a step by step instructions to connect to a
> hoast?
> The documentation seems very cryptic, and doesn't give directions.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2004-09-13 7:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-12 21:04 connecting to a hoast Ameer Armaly
2004-09-13 7:16 ` John T. Williams [this message]
2004-09-13 8:35 ` John T. Williams
2004-09-13 8:03 ` Ron Michael Khu
-- strict thread matches above, loose matches on Subject: below --
2004-09-13 16:09 Huber, George K RDECOM CERDEC STCD SRI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1095059805.2813.0.camel@client001 \
--to=jowillia@vt.edu \
--cc=jtwilliams@contextweb.com \
--cc=jtwilliams@vt.edu \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).