Article View: news.software.readers
Article #19284Programming my fist newsreader and having problems connecting.... Please help
From: siggson
Date: Sat, 17 Feb 1996 00:00
Date: Sat, 17 Feb 1996 00:00
72 lines
2657 bytes
2657 bytes
I took the following "working" finger program out of the book intitled
Internet Programming........
if (WSAStartup(WINSOCK_VERSION, &wsaData))
MessageBox(NULL, "Could not load Windows Sockets DLL.",
PROG_NAME, MB_OK|MB_ICONSTOP);
else // Resolve the host name
{
lpHostEnt = gethostbyname(HOST_NAME);
if (!lpHostEnt)
MessageBox(NULL, "Could not get IP address!", HOST_NAME,
MB_OK|MB_ICONSTOP);
else // Create the socket
{
nSocket = socket(PF_INET, SOCK_STREAM, DEFAULT_PROTOCOL);
if (nSocket == INVALID_SOCKET)
MessageBox(NULL, "Invalid socket!!", PROG_NAME,
MB_OK|MB_ICONSTOP);
else // Configure the socket
{
// Get the finger service information
lpServEnt = getservbyname("finger", NULL);
if (lpServEnt == NULL)
iFingerPort = htons(IPPORT_FINGER); //Use the well-known port
else
iFingerPort = lpServEnt->s_port;
// Define the socket address
sockAddr.sin_family = AF_INET; // Internet address family
sockAddr.sin_port = iFingerPort;
sockAddr.sin_addr = *((LPIN_ADDR)*lpHostEnt->h_addr_list);
// Connect the socket
nConnect = connect(nSocket, (LPSOCKADDR) &sockAddr,
sizeof(sockAddr));
if (nConnect)
MessageBox(NULL, "Error connecting socket!!", PROG_NAME,
MB_OK|MB_ICONSTOP);
else // Format and send the finger query
{
..
.
.
.
.
code if connect is OK
why do I get a connect failure when I change the "finger" string to
"nntp". Should I be able to connect to port 119 this way? Thanks for
the help.
Technical Details
Message-ID:
<3126494c.1030667@news.netvoyage.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <3126494c.1030667@news.netvoyage.net> Subject: Programming my fist newsreader and having problems connecting.... Please help Date: Sat, 17 Feb 1996 00:00:00 +0000 From: siggson@netvoyage.net Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 139772644 Organization: Netvoyage Internet Access Provider Newsgroups: news.software.readers