You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TcpClient not working with Maui when there is multiple connection like with wifi and mobile internet so TcpClient always connect to mobile internet not with wifi local n/w like below code
public async Task ConnectUsingTcpClientAsync(string serverAddress, int port)
{
var localAddress = IPAddress.Parse("192.168.0.100");
// Create a socket and bind it to the local address
var localEndPoint = new IPEndPoint(localAddress, 0);
using (var socket = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, ProtocolType.Tcp))
{
// Bind the socket to the local IP address
socket.Bind(localEndPoint);
// Create TcpClient using the socket
using (var client = new TcpClient(new IPEndPoint(IPAddress.Any, 0)))
{
// Assign the socket to TcpClient
client.Client = socket;
try
{
// Connect to the server
await client.ConnectAsync(serverAddress, port);
Console.WriteLine("Connected successfully over the specified network interface.");
}
catch (SocketException ex)
{
Console.WriteLine($"Connection error: {ex.Message}");
}
}
}
}
just to clarify confusion below are details of the phone i am using for testing and responses of ping command along with list of available interfaces:
Issue : not able to bind ping to any particular interface, getting error of "SO_BINDTODEVICE: Operation not permitted"
Requirement : we would like to connect to socket available on Wi-Fi interface(which does not have internet i.e local network) where phone has been connected to internet over differnet interface (either Cellular or USB)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
TcpClient not working with Maui when there is multiple connection like with wifi and mobile internet so TcpClient always connect to mobile internet not with wifi local n/w like below code
just to clarify confusion below are details of the phone i am using for testing and responses of ping command along with list of available interfaces:
Issue : not able to bind ping to any particular interface, getting error of "SO_BINDTODEVICE: Operation not permitted"
Requirement : we would like to connect to socket available on Wi-Fi interface(which does not have internet i.e local network) where phone has been connected to internet over differnet interface (either Cellular or USB)
Beta Was this translation helpful? Give feedback.
All reactions