Allow SOCK_SEQPACKET and other socket types.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 190
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
Thank you for the great library. Could I suggest a small improvement, which would allow any native OS sock types to be passed in from java? Something like the following could work:
In UnixDomainSocket.c, could I suggest changing:
s = socket(PF_UNIX, SOCK_TYPE(jSocketType), 0);
to:
s = socket(PF_UNIX, jSocketType, 0);
This would allow SOCK_SEQPACKET to be specified.
This would allow any sock type to be passed to the os.
To maintain compatibility with existing impls and OS's, you could detect and populate the type constants at compile and classload times:
jint Java_com_etsy_net_UnixDomainSocket_nativeSockTypeVal(jstring val){
#ifdef SOCK_STREAM
if(0==strcmp(val,"SOCK_STREAM")) return SOCK_STREAM;
#endif
#ifdef SOCK_DGRAM
if(0==strcmp(val,"SOCK_DGRAM")) return SOCK_DGRAM;
#endif
#ifdef SOCK_SEQPACKET
if(0==strcmp(val,"SOCK_SEQPACKET")) return SOCK_SEQPACKET;
#endif
// etc.... for different known enums
return -1;
}
//Add a quick static wrapper in UnixDomainSocket.java
//then in JUDS.java
static{
SOCK_STREAM = UnixDomainSocket.SockTypeVal("SOCK_STREAM");
SOCK_DGRAM = UnixDomainSocket.SockTypeVal("SOCK_DGRAM");
SOCK_SEQPACKET = UnixDomainSocket.SockTypeVal("SOCK_SEQPACKET");
//etc...
};
Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in UnixDomainSocket.c at the socket creation call, then inspect the related declarations in UnixDomainSocket.java and JUDS.java. Determine how the existing socket type constants are exposed and how compatibility is maintained. Done means SOCK_SEQPACKET and other supported native socket types can be passed from Java without breaking existing implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100