[Host] Suggest adding a function to obtain the local IP address #28
-
Or use other methods, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 13 replies
-
|
Do you wish get internal ip from |
Beta Was this translation helpful? Give feedback.
-
Hello!For get internal socket use Exampleusing Netly;
using Netly.Core;
using System.Net.Sockets;
public class Example
{
private UdpServer server = new UdpServer(false);
private Socket _socket = null;
private void Start()
{
server.OnOpen(() => print("Server started from"));
server.OnClose(() => print("Server closed!"));
server.OnError((e) => print($"Server error: {e}"));
server.OnModify((socket) => { _socket = socket; });
}
private IPEndPoint GetLocalEndPoint()
{
return (IPEndPoint)_socket.LocalEndPoint;
}
private IPEndPoint GetRemoteEndPoint()
{
return (IPEndPoint)_socket.RemoteEndPoint;
}
} |
Beta Was this translation helpful? Give feedback.
-
|
I don't understand! It's #28 (reply in thread) working? |
Beta Was this translation helpful? Give feedback.
-
Fixed: Host is null by default in TCP and UDP #30Problem:
|
Beta Was this translation helpful? Give feedback.
-
|
#28 (reply in thread) It's working? |
Beta Was this translation helpful? Give feedback.


lol. The error is because you get Host from not inited server.
- You must connect your server first
Well. When a Udp instance is created the Host is null because it has no past connection. So when you try to use udp.Host the value will be null. To solve this, your UDP must have already been connected at least once, in your example it is the same: