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

Implemented getsockname and poll #41600

Closed
wants to merge 1 commit into from
Closed

Implemented getsockname and poll #41600

wants to merge 1 commit into from

Conversation

MmAaXx500
Copy link
Contributor

@MmAaXx500 MmAaXx500 commented Aug 29, 2020

Implemented getsocknme in NetSocket and ENetSocket and poll in ENetSocket
This closes: godotengine/godot-proposals#2587

@Calinou Calinou added cherrypick:3.x Considered for cherry-picking into a future 3.x release enhancement topic:network labels Aug 29, 2020
@Calinou Calinou added this to the 4.0 milestone Aug 29, 2020
@Calinou
Copy link
Member

Calinou commented Aug 29, 2020

Can you explain some possible use cases for this feature?

@Calinou Calinou requested a review from Faless August 29, 2020 14:23
@MmAaXx500
Copy link
Contributor Author

I used for STUN NAT behavior discovery in my multiplayer implementation.
I think it's useful if someone need similar multiplayer.

@aaronfranke
Copy link
Member

@MmAaXx500 Is this still desired? If so, you should open a proposal, and this needs to be rebased and tested on the latest master branch. While there are no conflicts, rebasing is important so that reviewers can easily test the PR. A proposal is also needed so that we can better evaluate what the use cases are for this feature.

@MmAaXx500
Copy link
Contributor Author

I will put this into a draft until #48195 is resolved.

@MmAaXx500 MmAaXx500 marked this pull request as draft April 25, 2021 17:34
@aaronfranke aaronfranke removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Apr 25, 2021
getsockname in NetSocket and EnetSocket
poll in EnetSocket
@MmAaXx500
Copy link
Contributor Author

Updated the timeout handling according to #48203.
Now the Godot socket and Enet functions using the same unit, which is millisecond.

@MmAaXx500 MmAaXx500 marked this pull request as ready for review April 27, 2021 12:18
@@ -63,6 +63,7 @@ class NetSocket : public Reference {
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek = false) = 0;
virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent) = 0;
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0;
virtual Error getsockname(IP_Address &r_ip, uint16_t &r_port) = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This should likely be get_socket_name. Other methods here are not snake_case, but that's a separate problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And in godot.cpp too?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this name would need to be changed in many places if it's changed on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The godot.cpp is a separate class and is in the thirdparty folder, that's why I asked.
Ok, I'll modify it tomorrow (it's late at night here).

@Faless
Copy link
Collaborator

Faless commented Apr 27, 2021

See #48235 for a get_socket_address implementation in ENet.
And #47398 for the NetSocket one.

@MmAaXx500
Copy link
Contributor Author

Then this pr is useless, right?

@Faless
Copy link
Collaborator

Faless commented Apr 28, 2021

Then this pr is useless, right?

I think the only unimplemented bit there is enet_socket_wait.

@MmAaXx500
Copy link
Contributor Author

I think the only unimplemented bit there is enet_socket_wait.

Is it desirable? If so, I'll do my best in a separate pr.
BTW thanks for the better implementation of getsockname.

BTW2: Some hours ago I discovered the fact that I'm currently not using the wait. 😆 Probably implemented when I planned the things for my game.

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

Successfully merging this pull request may close these issues.

Implement getsockname and poll socket functions
5 participants