Skip to content

Conversation

@boivie
Copy link
Collaborator

@boivie boivie commented Aug 29, 2025

It currently has a single function, to query the library's version, to validate that the C++ FFI is working correctly.

@ValorZard
Copy link

Is the plan for dcsctp to be an alternative to https://github.com/sctplab/usrsctp or https://github.com/webrtc-rs/sctp-proto
Additionally, will this support RFC 8620 to fix potential head-of-line blocking issues?
Let me know if this is the wrong place to ask this!

@boivie boivie force-pushed the feature-cxx branch 4 times, most recently from e365ee9 to c1a35c5 Compare December 1, 2025 08:40
This adds CXX FFI for the dcSCTP rust library to integrate it into a C++
application.
To avoid polluting the default namespace.
@@ -0,0 +1 @@
/examples/main
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this to the top level .gitignore instead? Makes it easier to maintain.


fn delete_socket(socket: *mut DcSctpSocket) {
if !socket.is_null() {
unsafe {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a // SAFETY: ... comment explaining why this is safe

if !socket.is_null() {
unsafe {
// Re-take ownership of the Box and drop it.
let _ = Box::from_raw(socket);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do this instead?

drop(Box::from_raw(socket));

Comment on lines +8 to +17
#[derive(Debug)]
enum SocketState {
Closed,
Connecting,
Connected,
ShuttingDown,
}

extern "Rust" {
type DcSctpSocket;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to re-export dcsctp::api::SocketState here? Why do you need to create a duplicate inside the ffi module?

...but in that case I think you would need to return Box<SocketState> from state().

}
}

unsafe fn state(socket: *const DcSctpSocket) -> ffi::SocketState {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take a &DcSctpSocket instead of *const DcSctpSocket?

assert!(!socket.is_null());
&*socket
};
match socket.0.state() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part unsafe? Do you need the whole function block to be unsafe or can you limit it?

}
}

#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? It's pub so why would it complain about being unused? Does this have to be pub by the way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants