I need to know if I can create a WCF service using TFTP to get data from a device. I know I can create an application using C# to do this but I am trying to make it a web based application. Also the WCF needs to be hosted on IIS. I want to use a WCF service to start a connection and then pull an image from my device. When I run my code it does not seem to have a problem with the SendTo command but it always gives me a "System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.Socket.ReceiveFrom(...). Is this because I am using a netTcpBinding? Can I do this using a basic HTTP binding or something else? Or maybe it just isn't possible to create this service using WCF, thoughts??
Service Code Snippet:
public byte[] ipTftpGet(String xferFileName)
{...
byte[] rcvBuffer = new byte[5200];
....
try
{
ipEndPointFtp = new IPEndPoint(ipAddress, 69);
tftpS = new Socket(ipEndPointFtp.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
remoteEP = ipEndPointFtp;
// Request and Receive first Data Packet From TFTP Server
tftpS.SendTo(sndBuffer, nameLen, System.Net.Sockets.SocketFlags.None, remoteEP);
tftpS.ReceiveTimeout = 1000;
try
{
len = tftpS.ReceiveFrom(rcvBuffer, ref remoteEP);//tftpS.ReceiveFrom(rcvBuffer, ref remoteEP);
rcvBuffer[len] = 0x00;
}
catch (System.Net.Sockets.SocketException ex)
{
xferValid = false;
errMsgStr = ex.ToString();
}
}
Web.config:
<services>
<service behaviorConfiguration="mexBehavior"
name="ComService.ComService">
<endpoint address="ComService" binding="netTcpBinding"
contract="ComService.IComService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8090" />
<add baseAddress="http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>