delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1996/11/05/20:46:55

From: mansur AT pc DOT jaring DOT my (Mansuriatus Shahrir Amir)
Subject: Socket connect error ... with Msg " Not Owner"
5 Nov 1996 20:46:55 -0800 :
Sender: daemon AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <01BBCBDC.7A0AEA80.cygnus.gnu-win32@j5.brf22.jaring.my>
Mime-Version: 1.0
Original-To: "'GNU-Win32 Mailing List'" <gnu-win32 AT cygnus DOT com>
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019