Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

fortune: No such file or directory


devel / comp.lang.c / why does fcntl return an error?

SubjectAuthor
* why does fcntl return an error?stdcerr
`- Re: why does fcntl return an error?Joe Pfeiffer

1
why does fcntl return an error?

<640b2874-c3f9-45cf-830b-87ede7407623n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16781&group=comp.lang.c#16781

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:4756:: with SMTP id k22mr8541409qtp.193.1622312727645;
Sat, 29 May 2021 11:25:27 -0700 (PDT)
X-Received: by 2002:a37:e312:: with SMTP id y18mr9266076qki.39.1622312727451;
Sat, 29 May 2021 11:25:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.swapon.de!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 29 May 2021 11:25:27 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=24.87.40.64; posting-account=ITQB8goAAACqwP7vVe7b-QwIWpcBL1Ll
NNTP-Posting-Host: 24.87.40.64
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <640b2874-c3f9-45cf-830b-87ede7407623n@googlegroups.com>
Subject: why does fcntl return an error?
From: ron.egg...@gmail.com (stdcerr)
Injection-Date: Sat, 29 May 2021 18:25:27 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2177
 by: stdcerr - Sat, 29 May 2021 18:25 UTC

Hi,

I'm working on an FTPS client using the mbedtls library.
Now I'm struggling to even open the control channel, I have the following code:

if (inet_aton(host, &hisctladdr.sin_addr))
{
hisctladdr.sin_family = AF_INET;
hisctladdr.sin_port = htons(port);
strncpy(hostnamebuf, host, sizeof(hostnamebuf));
hostnamebuf[sizeof(hostnamebuf) - 1] = 0;
}
else
{
//LogPrint(ftpLogGet(), LOG_LEVEL_INFO, "Ftp::hookup IP dot format required");
iprintf("Ftp::hookup IP dot format required");
code = -1;
return (NULL);
}
hostname = hostnamebuf;
control_fd = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
if (control_fd < 0)
{
//LogPrint(ftpLogGet(), 0, "Ftp::hookup socket");
iprintf("Ftp::hookup socket");
code = -1;
close(control_fd);
control_fd = -1;
return (NULL);
}

iSockFlags = fcntl(control_fd, F_GETFL, 0);
if (iSockFlags == -1) {
iprintf("Ftp::hookup : F_GETFL on %d failed, errno %d\n",control_fd,errno);
return (NULL);
}
iSockFlags |= O_NONBLOCK;
iRc = fcntl(control_fd, F_SETFL, iSockFlags);

Where the fnctl() call returns -1 and errno is set to 88. This should work, should it not?

Re: why does fcntl return an error?

<1bim31z1st.fsf@pfeifferfamily.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16783&group=comp.lang.c#16783

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pfeif...@cs.nmsu.edu (Joe Pfeiffer)
Newsgroups: comp.lang.c
Subject: Re: why does fcntl return an error?
Date: Sat, 29 May 2021 15:07:46 -0600
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <1bim31z1st.fsf@pfeifferfamily.net>
References: <640b2874-c3f9-45cf-830b-87ede7407623n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="73452d9066a93131845bfe3ad7c530a9";
logging-data="10723"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BPeHrGwOxmRZGRJge1ffwfqh4VfjkoQg="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:T9QD9V4nSRayp+Hdzn+pr+xmxOI=
sha1:xUFulbmA+HZU0N3pWU7OOdh7nYs=
 by: Joe Pfeiffer - Sat, 29 May 2021 21:07 UTC

stdcerr <ron.eggler@gmail.com> writes:
> iSockFlags = fcntl(control_fd, F_GETFL, 0);
> if (iSockFlags == -1) {
> iprintf("Ftp::hookup : F_GETFL on %d failed, errno %d\n",control_fd,errno);
> return (NULL);
> }
>
> Where the fnctl() call returns -1 and errno is set to 88. This should work, should it not?

This doesn't directly answer your question, but if you call perror()
you'll get a brief explanation of the error, which is typically more
useful than the number. I typically call it on any system call error.

FWIW, error 88 means "Socket operation on non-socket"

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor