Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getprotobyname to Socket PMCs #606

Closed
ocharles opened this issue Aug 1, 2010 · 11 comments
Closed

Add getprotobyname to Socket PMCs #606

ocharles opened this issue Aug 1, 2010 · 11 comments

Comments

@ocharles
Copy link

ocharles commented Aug 1, 2010

I couldn't see any implementation of getprotobyname which seems like a standard function that should be available. This adds it to Socket PMCs.

I'm not entirely sure this is the correct approach - because normally you'd call this before creating a socket object. For PIR this is OK, but in something like Perl 6 this will create a Socket object to call getprotobyname, then destroy it, then probably create another one straight after.

Anyway, this is the best I could come up with given my extremely limited knowledge of Parrot - please advise!

Originally http://trac.parrot.org/parrot/ticket/1724

@ocharles
Copy link
Author

ocharles commented Aug 1, 2010

4974 byte attachment from ocharles
at http://trac.parrot.org/parrot/raw-attachment/ticket/1724/getprotobyname.patch

[malformed patch deleted, read the patch link above or the Git commit below]

@ocharles
Copy link
Author

ocharles commented Aug 1, 2010

5626 byte attachment from ocharles
at http://trac.parrot.org/parrot/raw-attachment/ticket/1724/getprotobyname-dynop.patch

[malformed patch deleted, read the patch link above]

@ocharles
Copy link
Author

ocharles commented Aug 1, 2010

Adds getprotobyname to Socket

@ocharles
Copy link
Author

ocharles commented Aug 1, 2010

Attached is a version of getprotobyname using the "socket_ops" dynop library - I think this is considerably better than adding it the PMC

@bacek
Copy link
Member

bacek commented Aug 3, 2010

Hello.

Second patch it really good. We just need someone on Win32 to complete it.

-- Bacek.

@nwellnhof
Copy link
Member

It looks like the new file src/dynoplibs/socket.ops is missing from the second patch. But I think the first approach is also OK.

@leto
Copy link
Member

leto commented Dec 12, 2012

Looks like this patch never made it in. @ocharles any way you can provide an updated patch? We really would like get_proto_by_name !

We are on Git now, so it should be less painful :)

@ocharles
Copy link
Author

Thanks for the ping @leto, I'll see what I can do... leave this open, but no promises until the new year :)

@leto
Copy link
Member

leto commented Dec 12, 2012

Just ported over the slightly bitrotten patch. Not sure if the code works. It needs some tests and some platform-specific bits for Windows and other non-Unixy flavors.

@leto
Copy link
Member

leto commented Dec 12, 2012

Looks like netdb.h doesn't get included early enough:


src/platform/generic/io.c:534:40: error: implicit declaration of function 'getprotobyname' is invalid in C99 [-Wimplicit-function-declaration]
    struct protoent * const protoent = getprotobyname(s);
                                       ^
src/platform/generic/io.c:534:29: warning: incompatible integer to pointer conversion initializing 'struct protoent *const' with an expression
      of type 'int'
    struct protoent * const protoent = getprotobyname(s);
                            ^          ~~~~~~~~~~~~~~~~~
src/platform/generic/io.c:538:28: error: incomplete definition of type 'struct protoent'
    proto_number = protoent->p_proto;
                   ~~~~~~~~^
src/platform/generic/io.c:534:12: note: forward declaration of 'struct protoent'
    struct protoent * const protoent = getprotobyname(s);
           ^

@rurban
Copy link
Member

rurban commented Dec 13, 2012

The first is solved with

#ifdef PARROT_HAS_HEADER_NETDB
#  include <netdb.h>
#endif

Now the macro PIO_GET_PROTO_BY_NAME is missing .

I'll rewrite it, the layout is suboptimal.

rurban pushed a commit that referenced this issue Dec 13, 2012
Put it into platform/generic/socket.c
@ocharles ocharles closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants