Mail Archives: cygwin/1996/11/05/20:46:55
I have this small program to get email from my pop server.
The program works in Linux but not on my office Win95 machine.
I have written a test program and managed to narrow down its error.
Here it is
****************************
Excerpt from program
*****************************
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <pwd.h>
#include "config.h"
struct in_addr saddr;
struct hostent *get_hostent(const char *host)
{
int c;
struct hostent *hostinfo;
c = *host;
if (isdigit(c))
{
saddr.s_addr = inet_addr(host);
hostinfo = gethostbyaddr((char *)&saddr, sizeof(struct in_addr), AF_INET);
if (hostinfo == NULL)
{
printf("Network is unreachable\n");
exit(EXIT_FAILURE);
}
}
else
{
hostinfo = gethostbyname(host);
if (hostinfo == NULL)
{
printf("gethostbyname Error\n");
fprintf(stderr, "%s: Unknown host\n", host);
exit(EXIT_FAILURE);
}
}
return hostinfo;
}
int start_connection(const char *host, unsigned short int port)
{
struct hostent *hostinfo;
struct sockaddr_in addr;
int sfd = socket(AF_INET, SOCK_STREAM, 0);
if (sfd == -1)
{
perror("socket: creating socket");
exit(EXIT_FAILURE);
}
printf("Socket created\n");
hostinfo = get_hostent(host);
printf("After get_hostent\n");
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr = saddr;
//Offending line ****************************************************************
if (connect(sfd, (struct sockaddr *)&addr, sizeof addr) == -1) //<----- Here's
{ //where it fails
perror(NULL); // with the mesg "Not owner"
exit(EXIT_FAILURE);
}
printf("Connected to %s.\n", hostinfo->h_name);
return sfd;
}
int main(void)
{
start_connection("mypop.mydomain.mycountry", 110);
return 0;
}
**************************************
End program
************************************
The offending line is marked above.
The error message is "Not owner"
Any idea why this is so.
I am running this in bash under win95 on Novell 4.1 compiled with Beta 17
The test program compiled fine using gcc -o test.exe test.c
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -