[gnutls-devel] Waiting for input data
Jaak Ristioja
jaak.ristioja at cyber.ee
Fri Feb 8 15:40:47 CET 2013
On 08.02.2013 16:38, Tim Ruehsen wrote:
> Am Friday 08 February 2013 schrieb Jaak Ristioja:
>> On 08.02.2013 15:54, Tim Ruehsen wrote:
>>> Maybe this code snippet/example from libmget (License LGPL3+) may help
>>> you: It assumes a non-blocking socket descriptor set by
>>>
>>> gnutls_transport_set_ptr(session, (void *)(ssize_t)sockfd);
>>
>> Well I have used (void *)(intptr_t) sockfd, but it doesn't solve the
>> real issue here, it just silences the compiler. When converted back
>> using (int)(intptr_t), it might not compare equal to the original.
>
> Couldn't you use a pointer to your 'socket'.
>
> gnutls_transport_set_ptr(session, &sockfd);
>
> and reading back with
> int sockfd = *(int *)gnutls_transport_get_ptr(session);
>
> If your sockfd is of type 'int'. If not, use a different type.
No I can't. The variable sockfd might go out of scope or get destroyed
otherwise, effectively invalidating the pointer.
Jaak
More information about the Gnutls-devel
mailing list