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

Added length type wrapper in sockaddr_any for convenience. #1492

Merged

Conversation

ethouris
Copy link
Collaborator

This adds a possibility to easily specify the forwarder for the len field in sockaddr_any usable with system functions.

The SRT API is using int type for length of the address specified by sockaddr*, whereas system functions use socklen_t on Linux (which resolves to various combinations) or int on Windows. To satisfy normal needs, the len field is of int type, but this way it can't be passed to system functions by pointer.

This makes it possible to pass a pointer to a system length type, as the system function require, and transparently bind it to the len field.

@ethouris ethouris added Priority: Low Type: Enhancement Indicates new feature requests [apps] Area: Test applications related improvements Impact: Optional labels Aug 20, 2020
@ethouris ethouris self-assigned this Aug 20, 2020
int64_t srctime = 0;
int stat = recvfrom(m_sock, data.data(), (int) chunk, 0, sa.get(), &si);
int stat = recvfrom(m_sock, data.data(), (int) chunk, 0, sa.get(), &sa.syslen());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dereferencing a temporal object SysLenWrapper::syslen.... 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Allowed, as long as you don't access it after it is deleted. We know it is not deleted until the current instruction finishes execution, so it won't happen before returning from the function. It actually does the same as the "temporary variable" solution used previously, just the trick is hidden inside.

@maxsharabayko maxsharabayko merged commit 6383693 into Haivision:master Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[apps] Area: Test applications related improvements Priority: Low Type: Enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants