Arreglos IP local

develop
Elena 2023-02-13 14:04:36 +01:00
parent 407d06bf00
commit 0f9a21eddc
5 changed files with 20 additions and 7 deletions

View File

@ -24,7 +24,7 @@ namespace OliviaAddIn
//devuelve -1 si no se ha podido crear socket
//0 si no se puede conectar
//1 si conectado
public bool conecta(string ip, int puerto)
public bool conecta(string ip, int puerto, string ip_local="")
{
termina();
try
@ -39,7 +39,7 @@ namespace OliviaAddIn
return false;
try
{
return str_socket_conecta(sc, ip, puerto) != 0;
return str_socket_conecta(sc, ip, puerto, ip_local) != 0;
}
catch
{
@ -120,7 +120,7 @@ namespace OliviaAddIn
unsafe public static extern IntPtr str_socket_crea();
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_conecta(IntPtr soc, String ip, int puerto);
unsafe public static extern int str_socket_conecta(IntPtr soc, String ip, int puerto, String ip_local=null);
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_envia(IntPtr soc, String txt);//solo este

View File

@ -69,7 +69,7 @@ namespace OliviaAddInPro.Model
public OliviaConf()
{
Ip = "0.0.0.0";
Ip = "127.0.0.1";
Puerto = 19995;
TiempoOutSocket = 20;
}

View File

@ -332,10 +332,11 @@ namespace OliviaAddInPro.Model
try
{
string[] ips = OliviaGlob.dame_local_ips();
if (ips != null && ips.Length > 0)
/*if (ips != null && ips.Length > 0)
Conexion.Ip = ips[0];
else
Conexion.Ip = "127.0.0.1";
Conexion.Ip = "127.0.0.1";*/
Conexion.Ip = "127.0.0.1";
resp.Value = true;
return resp;
}

View File

@ -8,13 +8,25 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Debug|x64.ActiveCfg = Debug|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Debug|x64.Build.0 = Debug|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Debug|x86.ActiveCfg = Debug|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Debug|x86.Build.0 = Debug|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Release|Any CPU.Build.0 = Release|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Release|x64.ActiveCfg = Release|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Release|x64.Build.0 = Release|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Release|x86.ActiveCfg = Release|Any CPU
{10742570-CF59-42F2-BEA2-2A38002A06EE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -178,7 +178,7 @@ namespace OliviaAddInPro.Services
{
if (!conectado)
{
if (!soc.conecta(Ip, Puerto))
if (!soc.conecta(Ip, Puerto,Ip))
{
conectado = false;
return false;