Hi,
I have to do one more integration between my application and a TCP/IP controller.
The supplier just sent me the code with the programming of the features in C#, code that I already partially converted to Cobol.
Now my question is how and what do I call these features (for example the OPEN and CLOSE functions).
I type below a part of the code in C# that was sent to me.
using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace NuxIOAPI2
{
public class ANuxIOII : NuxIOBase
{
protected int nRandomtemp;
protected Socket m_clientSocket; //UDP
protected AsyncCallback m_pfnCallBack;
protected IAsyncResult m_result;
protected ArrayList _messages = new ArrayList();
protected IPEndPoint _ipEndpoint;
private class SocketPacket
{
public System.Net.Sockets.Socket thisSocket;
public byte[] dataBuffer = new byte[1024];
}
public static bool WriteErrorLog(string strText)
{
System.Diagnostics.Trace.WriteLine(strText);
string strPathName = @"C:\\NuxIOAPI.log";
bool bReturn = false;
string strException = string.Empty;
try
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(strPathName, true);
sw.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + " : " + strText);
sw.Flush();
sw.Close();
bReturn = true;
}
catch (Exception)
{
bReturn = false;
}
return bReturn;
}
public ANuxIOII()
{
m_clientSocket = null;
_strModelo = "NuxIOII";
}
public override int Open(string localAddress)
{
try
{
m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint endPoint;
if (localAddress != "")
{
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
int nIPIndex = -1;
for (int a = 0; a < hostEntry.AddressList.Length; a++)
if (hostEntry.AddressList[a].AddressFamily == AddressFamily.InterNetwork)
{
nIPIndex = a;
break;
}
endPoint = new IPEndPoint((localAddress == "") ? hostEntry.AddressList[nIPIndex] : IPAddress.Parse(localAddress), PortNo);
m_clientSocket.Bind(endPoint);
this._ipEndpoint = endPoint;
}
else
{
endPoint = new IPEndPoint(IPAddress.Any, PortNo);
m_clientSocket.Bind(endPoint);
}
WriteErrorLog("Socket Created at :" + endPoint.Address);
return WaitForDataUdp();
}
catch (Exception se)
{
m_clientSocket = null;
System.Diagnostics.Trace.WriteLine(se.Message);
LastError = se.Message;
return 0;
}
}
public override void Close()
{
try
{
if (m_clientSocket != null)
m_clientSocket.Close();
m_clientSocket = null;
}
catch (Exception se)
{
System.Diagnostics.Trace.WriteLine(se.Message);
LastError = se.Message;
}
}
}
}
There are some parts that I can't convert with Cobol Converter (eg this complete piece of code). I have to convert in pieces. I am once again waiting for your help. If necessary, I can send all the information that the supplier has given me.
Best regards
Alberto Ferraz



