|
TCP/IP sent to localhost, uses Named Pipes under the hood I'm told. That's a reasonable swap.
Otherwise you have two basic options. If you want to use Named Pipes in C# for a general mechansism then its off to P/Invoke land. But unless you have to interface to an older C/C++ program that used Named Pipes, you might consider leveraging some of C#'s data structures and particularly the TCP classes.
Secondly, if you are using SQL Server, Microsoft has carried over Named Pipes for that. That's easy to take advantage of.
I guess there is one 3rd option which may or may not make sense. Since you have a heap of code in C++, you could hobble together a C# callable DLL and provide the underlying Named Pipe support.
In sum, Named Pipes appear to have been relegated to performance driven 3GL/2GL apps. With some effort you can force an implementation in C# but you have to ask: "why am I doing this?"
Good luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
mcljava wrote: TCP/IP sent to localhost, uses Named Pipes under the hood I'm told. That's a reasonable swap.
Otherwise you have two basic options. If you want to use Named Pipes in C# for a general mechansism then its off to P/Invoke land. But unless you have to interface to an older C/C++ program that used Named Pipes, you might consider leveraging some of C#'s data structures and particularly the TCP classes.
Secondly, if you are using SQL Server, Microsoft has carried over Named Pipes for that. That's easy to take advantage of.
Yeah, but the trick is figuring out how to use these classes and if they will actually work or not.
I have no control over the other program I'm interfacing with, I just have a pair of named pipes for talking and listening and a list of commands I can expect to receive and replies I need to make.
Whether the TCP classes happen to use pipes or not doesn't mean anything to me. I need to open a specific pipe, wait for a command from another program (which is not of my design or control) and give it a response telling it my status. That program uses named pipes and it's the only hook available for communication.
mcljava wrote: Secondly, if you are using SQL Server, Microsoft has carried over Named Pipes for that. That's easy to take advantage of.
Nope, not using SQL server.
mcljava wrote: With some effort you can force an implementation in C# but you have to ask: "why am I doing this?"
Well, I'm doing it because that's my job...LOL. Unfortunately every time a new technology comes along half the world jumps on the bandwagon thinking it's the next best thing since cake and the other half is relegated to trying to make it work with all the stuff that's been done before. In this example, I have a c# .NET namespace which is the only way to access one piece of hardware, and a named pipe scheme which is the only way to talk to the master program. I'm caught in the middle and have no say in how either one is done.
I really appreciate you giving this one a shot, truly, but I'm afraid I'm left just as confused as to how to accomplish this as I was before.
Anyone know of any books, texts, articles that covers this, or at least dance around the topic enough that I might glean some ideas?
Could there be some way to tap into named pipes using the Win32 API? The Win32 API examples I've seen all look awfully ugly when brought into C# and none even come close to touching on named pipes as far as I can find.
All hints and suggestions welcomed
Phil
|
|
|
|
|
Phil,
Fire up google, and ... "C# named pipes" - it will lead you to at least a dozen or so C# Named Pipe Examples.
Good Luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
Ah whew...I looked again, thanks.
Obviously this was the first thing I did when I first took this on. Perhaps my google skills need polish, I don't know.
Everything I found seemed to be pointed at the new IPC remoting stuff that's in .NET 2.0.
I Found an example on codeguru and it does compile and run with my 1.1, so I'm golden. It's buried inside InterProcessCommunication stuff. I guess since my C++ and MFC experience all had it built into CreateFile and it was right up front and as basic as opening a file I assumed the CSharp would be there too (obviously it isn't)
Thanks for the gentle shove in the right direction
Just what I needed.
|
|
|
|
|
G’Day,
Actually I have a problem with my network program. Can you help me ?.
Actually my laptop is in a WLAN. Means my IP address is local to this LAN. I am developing a client / server software. In this I want to communicate to a P.C in a different network. Eg. My loacl IP is 192.168.0.15 and the other P.C (which I want to communicate to) is 192.168.1.23. But these IPs are there local IPs.
The problem comes in the following code.
private void Form1_Load(object sender, System.EventArgs e)
{
Thread mythread = new Thread(new ThreadStart(serverThread));
mythread.Start();
}
public void serverThread()
{
UdpClient udpClient = new UdpClient(999);
while(true)
{
IPEndPoint RemoteEndPoint = new IPEndPoint(IPAddress.Any,0); // listing for reply
Byte[] receiveBytes = udpClient.Receive(ref RemoteEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
}
}
private void btnReplay_Click(object sender, System.EventArgs e)
{
string ips = “192.168.0.1.23” ;
UdpClient udpClient = new UdpClient();
udpClient.Connect(ips,999);
Byte[] sendBytes = Encoding.ASCII.GetBytes(“Hi I am testing”); // sending reply
udpClient.Send(sendBytes,sendBytes.Length);
}
The problem is
1. I want to specify the IP address of the destination machine
string ips = “192.168.0.23” ;
Here I iam specifying the local Ip of the machine which is in a different network.
How can I communicate to the destination machine ?
How NAT works ?
Can you guide me in a proper way using c# ?
Thanks in advance
Cheers
|
|
|
|
|
Not sure if this is a direct answer to your problem or not, but are you sure your machine can even see the other one with the way the IP addresses are set up?
In other words, what are the subnet masks on the machine.
If either one is set to the standard 255.255.255.0 these two machines will not be able to see one another regardless of how your program is coded becaues the network mask blocks/prevents all IP traffic except on your local network.
Quick way to test it is to pull up a command prompt on your machine then type:
ping 192.168.1.23...if you get a reply then all should be ok.
By the way, as I was checking back in your message to make sure I typed the right IP address, I notice your program reads:
string ips = “192.168.0.23” ;
Shouldn't that be "192.168.1.23";???????????????
|
|
|
|
|
Thank You. If I ping to 192.168.1.23 . It shows the message " Request timed out". Because it is the local IP of another network. I dont know how to communicate to a client which is in another network ,if I have the global IP of that network. Thank you for your advice
Cheers
Jijo
|
|
|
|
|
Yup, I had a feeling it wsa something along those lines.
You'll probably need more detailed info on the network configuration. For instance is port forwarding enabled, firewalls, etc. I can think of several things that will prevent these two machines from establishing a UDP connection.
You can start by finding out your public IP address by using something like:
http://www.whatismyipaddress.com
Maybe if you run it on both machines you can get a start, but since your machines are probably set to dynamic IP addresses it's going to change each time you reboot either machine.
All I can advise at this point is to use the ping command as you try various settings and addresses. A lot easier than changing your program and re-compiling to find out if the two machines are able to talk to see each other.
|
|
|
|
|
Hi
I have a DB of documents that I want to open/save from a web browser.
I have set the ContentType of my response to be "text/richtext"
and I have Response.BinaryWrite(byte[] mydata)
I get an open/save dialog box like I wanted to, but the file it is asking me to open/save is my asp page...e.g. ResultsPage.aspx.
How come its not asking me to save my document?
Would appreciate any help. been stuck on it for days!
Thanks!
melissa
|
|
|
|
|
I have a .wsdl file and I want to get information from it. I have tried the following:
<br />
[System.Web.Services.Protocols.SoapRpcMethod(<br />
RequestNamespace = "somehttp", <br />
ResponseNamespace = "somehttp")]<br />
[return: System.Xml.Serialization.SoapElementAttribute("return")]<br />
public className get_attr(string username, string password)<br />
{<br />
object[] me = new object[] { username,password };<br />
object[] results = this.Invoke("get_attr",me);<br />
return ((className)(results[0]));<br />
}<br />
Of course, somehttp is a valid http:// address, and get_attr is an operation name inside the .wsdl. When I run this, the "className" object I return is empty (not null, just empty). What would be the simplest way to get information from the .wsdl and also, is C# (without ASP.Net) able to accomplish this. Thanks for all the help.
Mike - I love to program!
-- modified at 17:27 Thursday 16th March, 2006
|
|
|
|
|
I'm trying to make an application that supports plugins but I'm having some troubles with my interface. In the interface I define a function like this:
string edplugin_HandleCommand( string[] command, string username );
And in my test plugin I implement it like this:
public string edplugin_HandleCommand( string[] command, string username )
{
return "Successful!";
}
For some reason when I have the user parameter on the function I get the following error when I try to "load" the plugin with Activator.CreateInstanceFrom() into the main application:
Additional information: Method edplugin_HandleCommand in type edbot.CEDBotPlugin from assembly plugin_test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null does not have an implementation.
When I remove the 2nd parameter from the interface as well as the implementation the program runs flawlessly. Is there some kind of limitation to an interface that won't let me have more than one parameter?
Thanks for the help!
|
|
|
|
|
Your plugin probably was referencing the wrong assembly when building it. TIP: use auto incremented version numbers so you can be sure You can remove it once u have your build proces sorted
|
|
|
|
|
Yup! That was the problem. It was a dumb mistake on my part. I forgot to set the binary path to the place the application was looking for it so it kept trying to load the old assembly that I'd manually copied there. Once I fixed that it works again. Thanks a lot for the help!
-- modified at 9:53 Friday 17th March, 2006
|
|
|
|
|
Does anyone of you can answer to my question?
I want use regular expression in my text box to validate text. For example reg. expression like this : "[0-9][0-9]-[0-9][0-9][0-9]" accepts only for example "43-456" text. What if I enter "54-8f5" ? .NET Regular Expressions tells me that this text is not correct. But it doesn`t tell me which character is invalid.
My problem is that I want .NET Regular Expressions show me which character (which character index in this incorrect string) is invalid.
Please help me...
-- modified at 15:53 Thursday 16th March, 2006
Is it possible with .NET regular expressions?
|
|
|
|
|
No. Sorry. You can only perform positive matching with .NET REs.
|
|
|
|
|
Are you absolutely sure?
Anyway...Thank you very much... You let me safe so much time of my research...
|
|
|
|
|
|
You sugested that in a more difficult regular expression the better thing to do is to write my own regular expression parser?
Do you have any idea how I suppose to do this?
|
|
|
|
|
conrado7 wrote: You sugested that in a more difficult regular expression
I meant an easier RE as per your example. It will probably just be easier to read the string char by char
|
|
|
|
|
I`ve been wondering about creating my own parser, but in more difficult RE it`s very hard to build it.
For e.g. ^(/d{2}-/d{3}){3,}$ Reg Exp... How can my parser read this to show me wich character is invalid?
Any ideas?
|
|
|
|
|
The only way is to use sub group matching as per my example earlier.
|
|
|
|
|
Hello,
I have the form that contains the tabControl, that in turn has 2 tabPages. How can I control the activated tabPages upon Form Loading? Any ideas? It seems that tabPage1.Select() does not work, I guess because the tabControl has not being loaded yet.
Thank you.
|
|
|
|
|
TabControl.SelectedTab = tabPage;
Ed
|
|
|
|
|
Hello all,
I am trying to create a Smart Mobile/GPS application using .Net 2003 framework. In addition for the GPS support I am using OpenNETCF SDK 1.4 library. I am having problems reading in data from the GPS . The following is my code snippet:
private void button1_Click(object sender, System.EventArgs e)
{
gps.BaudRate = OpenNETCF.IO.Serial.BaudRates.CBR_9600;
gps.ComPort = "COM1:";
textBox1.Text = gps.ToString() + "\n";
gps.GpsSentence += new OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
gps.GpsCommState += new OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
gps.Start();
}
private void gps_GpsSentence(object sender,GpsSentenceEventArgs e)
{
MessageBox.Show("calling");
textBox1.Text += "calling" ;
textBox1.Text += e.Sentence + " ";
}
private void gps_GpsCommState(object sender,GpsCommStateEventArgs e)
{
switch(e.State)
{
case OpenNETCF.IO.Serial.GPS.States.Running:
textBox1.Text += "GPS Started";
break;
case OpenNETCF.IO.Serial.GPS.States.Stopped:
textBox1.Text += "GPS Stop";
break;
}
}
When I run the code using a pocket PC emulator , the code fires gps_GpsCommState event (it always shows the message GPS started even when its not connected) , and more importantly it does not fire the gps_GpsSentence event ever. What is the problem?? Could anyone help me out with this. I would be greatly obliged. If you of any other way to read in data pls lemme know. Also let me know what is the problem with the code.
|
|
|
|
|
I was actually having the same problem a few days ago. I almost went with opennetcf, then found that vs 2005 has a 'serialport' control that will let you do this VERY easily. One thing I found was that on mine, the gps data is coming in through COM7 (an HP iPAQ). I'm not too familiar with that library, but another thing is that in all the examples I saw, you have to also set the stopbits to 1, paritybits to none, and databits(I think that's what it's called) to 8. Hope I've provided some help. If you get this up and working correctly please post back so that I can see what your solution is in case something screwy happens with vs2005 and I have to go back to using 2003 for this project.
My Music | My Pics | My Articles
BlackDice
|
|
|
|