tcpip connect with specific local endpoint

0
hi, when connecting to a server, I need to be able to specify the local endpoint by myself since the local computer has several network cards and VLAN. this way, the primary IP is not the one I can use. the problem is that the local endpoint property is read-only. any way to overdrive this ?
edited 8/5/2019 9:10:16 AM
asked 8/3/2019 8:10:11 PM
add a comment

3 Answers

0
problem solved. I find the solution/sample on the forum of a component competitor class i_socket : ISocketFactory { public ISocket CreateSocket() { return new ProxySocket(My_socket); } } public static Socket My_socket; public int DoSendSmtp(ComponentPro.Net.Mail.MailMessage email) { ComponentPro.Net.Mail.Smtp smtp; ISocketFactory factory; factory = new i_socket(); smtp.SetSocketFactory(factory);
 
answered 8/9/2019 8:09:28 AM
add a comment
0
i try to understand how to use setsocketfactory but it is not clear. I dont find sample with this kind of cases and the help file does not help let say, the current server has 2 network cards : one with ip 192.168.1.2 and one with 192.168.10.2 using standard tcpip instruction , windows will use the defaut 192.168.1.2 but if I want to connect via the second network card, I need to do something like : ip = "192.168.10.2"; iMail_ServerPort = 25; RemoteEndPoint = new IPEndPoint(m_ip, iMail_ServerPort); ipadr = IPAddress.Parse(ip); localEndPoint = new IPEndPoint(ipadr, 0); socket.Bind(localEndPoint); socket.Connect(RemoteEndPoint); what make complex is that setsocketfactory does not use sockets but a custom class isockets can you provide a sample ? PS : this can also be necessary when using other component than smtp
 
answered 8/8/2019 10:52:45 PM
add a comment
0
Can you post the code you want to achieve? That prop cant be set since it has a getter only. Its underlying code is `_socket.LocalEndPoint`. Plz use `SetSocketFactory` to create your own socket instead.
 
answered 8/5/2019 9:15:44 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged smtp or ask your own question.