954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How To Interface with x25

Hi Friends
I am Doing Application to interface with the x25.......
The Company Eiconcard provided the sample code but that is in c language. I want to develop it in c#. Below I write the Code which is equivalent to c Language code but its not working properly.
Plz Help me.............

using System;
using System.Runtime.InteropServices ;
using System.Data.Common ;
using System.Threading;

namespace UdayChat
{
///
/// Summary description for MyClass.
///
public class MyClass
{
public MyClass()
{
}
public struct x25Data
{
public string Xd_Data;
public int Xd_Len;
}
public struct x25doneinfo
{
public int xi_len;
public string xi_buf;
public int xi_cid;
public int xi_cmd;
public int xi_info;
public int xi_retcode;
[MarshalAs(UnmanagedType.AsAny)] object xi_ref;
};
////////
//public x25doneinfo doneinfo = new x25doneinfo();
public delegate void PostDelgate(ref x25doneinfo doneInfo );
//public const X25NULLFN (void (intPtr)) ;



[MarshalAs(UnmanagedType.FunctionPtr)] PostDelgate post;
const int DATA_SIZE =128;


public static x25Data sUdata = new x25Data() ;
public static x25Data sFacil = new x25Data() ;// size of data buffer */
[DllImport("Ex25.dll")]
public static extern string x25version(char []ss);
[DllImport("Ex25.dll")]
public static extern int x25init(int message,uint uMsg);
[DllImport("Ex25.dll")]
public static extern int x25error();
[DllImport("Ex25.dll")]
public static extern string x25alloc(int DATA_SIZE);
[DllImport("Ex25.dll")]
public static extern int x25exit();
[DllImport("Ex25.dll")]
public static extern int x25xcall(
int Cid,
int X25NOWAIT,
int iPort,
int iInfo,
x25Data sFacil ,
x25Data sUsage ,
string Remote,
string Local,
IntPtr xx);
[DllImport("Ex25.dll")]
public static extern int x25recv(
int Cid,
string cpRecvBuf,
int DATA_SIZE,
int iInfo,
PostDelgate post);
[DllImport("Ex25.dll")]
public static extern int x25send(
int Cid,
string cpRecvBuf,
int DATA_SIZE,
int iInfo,
PostDelgate post);
public string Local ;
public int Cid=0,X25NOWAIT=0,iPort=0,iInfo=0,intFlag=0;
public string Remote,StrError;
public static string cpRecvBuf;
public static char [] argv = new char[50];
public Thread Thread1,Thread2;

public string DispVersion()
{
char [] ss = new char [150] ;
string str;
str = x25version( ss);
return str;
}
public string ExecuteCall(int port,string Data)
{
int intFlag=0,intPort=0;
string strcpSendBuf="",strRecvBuff="";

intFlag = x25init(0,0);
if(intFlag<0)
{
abort_prog_no_x25exit("x25init");
}
/////////// Allocate Buffer.
strcpSendBuf = x25alloc(DATA_SIZE);
if(strcpSendBuf ==null)
{
abort_prog_no_x25exit("x25alloc");
}
strRecvBuff = x25alloc(DATA_SIZE);
if(strRecvBuff ==null)
{
abort_prog_no_x25exit("x25alloc");
}
Form1 fm = new Form1 ();
intPort = port;
sUdata. Xd_Data = Data;
sUdata.Xd_Len = Data.Length;
sFacil.Xd_Data = "1 128";
sFacil.Xd_Len = Data.Length ;
Local = "";
Remote = "4460700";

//////// if(argv[3].ToString().CompareTo("/c")==0)
//////// {
//////// Console.WriteLine ("MODE:\tCALLER\n");
StrError = do_call();
////// }
////// else
////// {
//////////// Console.WriteLine ("MODE:\tListen\n");
//do_Listen();
////// }
return StrError ;
}

public String do_call()
{
StrError = "Calling...";
//////// if(x25xcall( Cid, X25NOWAIT, iPort, iInfo, sFacil , sUdata , Remote, Local, post) < 0)
//////// {
//////// StrError= abort_prog("x25xcall");
//////// return StrError;
//////// }
sFacil.Xd_Data = "1 128";
sFacil.Xd_Len =5;
sUdata.Xd_Data ="uday";
sUdata.Xd_Len = 4;
int intCall =0;
intCall =x25xcall( 2, 0, 2, 0, sFacil , sUdata , "4460700", ".\\uday", IntPtr.Zero ) ;
if( intCall< 0)
{
StrError= abort_prog("x25xcall");
return StrError;
}
do_common();
return StrError ;
}

void do_common()
{
Thread1 = new Thread( new ThreadStart(recvThread));
Thread1.Start();
Thread2 = new Thread( new ThreadStart(recvThread));
Thread2.Start();
}

public void recvThread()
{
Boolean BoolFlag = true;
while(BoolFlag )
{

if(x25recv(Cid,cpRecvBuf,DATA_SIZE,iInfo,post) < 0)
{
abort_prog("x25recv");
}
BoolFlag = false;
}
}
public void sendThread()
{
Boolean BoolFlag = true;
while(BoolFlag )
{

if(x25send(Cid,cpRecvBuf,DATA_SIZE,iInfo,post) < 0)
{
abort_prog("x25recv");
}
BoolFlag = false;
}
}

/////////////////// Error Functions
public string abort_prog_no_x25exit(string CpStr)
{
int intErrorNo=0;
intErrorNo = x25error();
return StrError + intErrorNo.ToString ();
}
public string abort_prog(string cpStr)
{
StrError = StrError + cpStr;
StrError = StrError + "ERROR: " + x25error();
StrError = StrError + setPrgEnd("\n");
return StrError;
}
public string setPrgEnd(string cpStr)
{

StrError = StrError + cpStr;
StrError = abort_prog_x25exit("\nCan't set End Event, Fatal Error\n");
return StrError;
}
string abort_prog_x25exit(string cpStr)
{
StrError = StrError + cpStr;
StrError= StrError + "ERROR:" + x25error();
if(x25exit() < 0)
{
StrError = abort_prog_no_x25exit("x25exit");
}
return StrError ;
}
////////////////// Error End Functions................
}
}

you will get the more info on
http://www.eicon.com/support/training/slideshow2.asp?go=section&c=X25_Theory&s=150

Thanks in Advance.

Regards,
Uday Shelar.

Attachments UdayChat.zip (144.42KB)
udayshelar
Newbie Poster
3 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

Hi Friends I am Doing Application to interface with the x25....... The Company Eiconcard provided the sample code but that is in c language. I want to develop it in c#. Below I write the Code which is equivalent to c Language code but its not working properly. Plz Help me.............

using System; using System.Runtime.InteropServices ; using System.Data.Common ; using System.Threading; namespace UdayChat { /// /// Summary description for MyClass. /// public class MyClass { public MyClass() { } public struct x25Data { public string Xd_Data; public int Xd_Len; } public struct x25doneinfo { public int xi_len; public string xi_buf; public int xi_cid; public int xi_cmd; public int xi_info; public int xi_retcode; [MarshalAs(UnmanagedType.AsAny)] object xi_ref; }; //////// //public x25doneinfo doneinfo = new x25doneinfo(); public delegate void PostDelgate(ref x25doneinfo doneInfo ); //public const X25NULLFN (void (intPtr)) ;

[MarshalAs(UnmanagedType.FunctionPtr)] PostDelgate post; const int DATA_SIZE =128;

public static x25Data sUdata = new x25Data() ; public static x25Data sFacil = new x25Data() ;// size of data buffer */ [DllImport("Ex25.dll")] public static extern string x25version(char []ss); [DllImport("Ex25.dll")] public static extern int x25init(int message,uint uMsg); [DllImport("Ex25.dll")] public static extern int x25error(); [DllImport("Ex25.dll")] public static extern string x25alloc(int DATA_SIZE); [DllImport("Ex25.dll")] public static extern int x25exit(); [DllImport("Ex25.dll")] public static extern int x25xcall( int Cid, int X25NOWAIT, int iPort, int iInfo, x25Data sFacil , x25Data sUsage , string Remote, string Local, IntPtr xx); [DllImport("Ex25.dll")] public static extern int x25recv( int Cid, string cpRecvBuf, int DATA_SIZE, int iInfo, PostDelgate post); [DllImport("Ex25.dll")] public static extern int x25send( int Cid, string cpRecvBuf, int DATA_SIZE, int iInfo, PostDelgate post); public string Local ; public int Cid=0,X25NOWAIT=0,iPort=0,iInfo=0,intFlag=0; public string Remote,StrError; public static string cpRecvBuf; public static char [] argv = new char[50]; public Thread Thread1,Thread2; public string DispVersion() { char [] ss = new char [150] ; string str; str = x25version( ss); return str; } public string ExecuteCall(int port,string Data) { int intFlag=0,intPort=0; string strcpSendBuf="",strRecvBuff="";

intFlag = x25init(0,0); if(intFlag<0) { abort_prog_no_x25exit("x25init"); } /////////// Allocate Buffer. strcpSendBuf = x25alloc(DATA_SIZE); if(strcpSendBuf ==null) { abort_prog_no_x25exit("x25alloc"); } strRecvBuff = x25alloc(DATA_SIZE); if(strRecvBuff ==null) { abort_prog_no_x25exit("x25alloc"); } Form1 fm = new Form1 (); intPort = port; sUdata. Xd_Data = Data; sUdata.Xd_Len = Data.Length; sFacil.Xd_Data = "1 128"; sFacil.Xd_Len = Data.Length ; Local = ""; Remote = "4460700"; //////// if(argv[3].ToString().CompareTo("/c")==0) //////// { //////// Console.WriteLine ("MODE:\tCALLER\n"); StrError = do_call(); ////// } ////// else ////// { //////////// Console.WriteLine ("MODE:\tListen\n"); //do_Listen(); ////// } return StrError ; } public String do_call() { StrError = "Calling..."; //////// if(x25xcall( Cid, X25NOWAIT, iPort, iInfo, sFacil , sUdata , Remote, Local, post) < 0) //////// { //////// StrError= abort_prog("x25xcall"); //////// return StrError; //////// } sFacil.Xd_Data = "1 128"; sFacil.Xd_Len =5; sUdata.Xd_Data ="uday"; sUdata.Xd_Len = 4; int intCall =0; intCall =x25xcall( 2, 0, 2, 0, sFacil , sUdata , "4460700", ".\\uday", IntPtr.Zero ) ; if( intCall< 0) { StrError= abort_prog("x25xcall"); return StrError; } do_common(); return StrError ; }

void do_common() { Thread1 = new Thread( new ThreadStart(recvThread)); Thread1.Start(); Thread2 = new Thread( new ThreadStart(recvThread)); Thread2.Start(); }

public void recvThread() { Boolean BoolFlag = true; while(BoolFlag ) { if(x25recv(Cid,cpRecvBuf,DATA_SIZE,iInfo,post) < 0) { abort_prog("x25recv"); } BoolFlag = false; } } public void sendThread() { Boolean BoolFlag = true; while(BoolFlag ) { if(x25send(Cid,cpRecvBuf,DATA_SIZE,iInfo,post) < 0) { abort_prog("x25recv"); } BoolFlag = false; } } /////////////////// Error Functions public string abort_prog_no_x25exit(string CpStr) { int intErrorNo=0; intErrorNo = x25error(); return StrError + intErrorNo.ToString (); } public string abort_prog(string cpStr) { StrError = StrError + cpStr; StrError = StrError + "ERROR: " + x25error(); StrError = StrError + setPrgEnd("\n"); return StrError; } public string setPrgEnd(string cpStr) { StrError = StrError + cpStr; StrError = abort_prog_x25exit("\nCan't set End Event, Fatal Error\n"); return StrError; } string abort_prog_x25exit(string cpStr) { StrError = StrError + cpStr; StrError= StrError + "ERROR:" + x25error(); if(x25exit() < 0) { StrError = abort_prog_no_x25exit("x25exit"); } return StrError ; } ////////////////// Error End Functions................ } }

you will get the more info on http://www.eicon.com/support/training/slideshow2.asp?go=section&c=X25_Theory&s=150

Thanks in Advance.

Regards, Uday Shelar.

Dear Uday,
i am also struggling the same code what u did , i need help from u can u tell me the solution, for ex25.dll how to interface that, i am thankful if u told that solution, i need very urgent. my mail id :-yb_bhaskar@yahoo.com . i am waiting for your reply

thanks
bhaskar

balabhaskar
Newbie Poster
3 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You