 |
|
 |
I have downloaded your example “Real Time TCP/IP using C#” from www.codeproject.com .
I have problem in “ReadSocket()” function on the line of “this.listView2.Items.Add(newItem);” .
when program reach to this line, couldn’t run hence in Exception I have this message:
{"Cross-thread operation not valid: Control 'listView2' accessed from a thread other than the thread it was created on."}
Program is working but I cannot see users in 'listView2'.
Would you please help to solve the problem.
Thank you very much in advance.
Hossein
|
|
|
|
 |
|
 |
Thanks a lot.Right now, i had idea abt how to connect a system through TCP protocol. Once again i thanks to you.
Raja
|
|
|
|
 |
|
 |
Thanks Jibin and Thanks Ian !
For me it's a perfect compressed source of information.
I wonder where you get your informations from - MS workshops or ...?
Studying surfing and reading articles and samples MSDN and and..
learning by doing I never found such a cross-explained argumentation about threads. ! Perfect! Thanks for that -
tilman * germany
|
|
|
|
 |
|
 |
One of the MaskedTextBox's method is missing causing error. I guess it is customed made component, maybe the component should be included in the project.
Can someone help!
|
|
|
|
 |
|
|
 |
|
 |
Hi,
even i found the same error.
Actually the constructor of maskedtextbox used is private member of that class and hence the erroe.
The MaskedTextBox.dll has to be modified for that.
unfortunately we are not provided with the source code of maskedtextbox.dll
|
|
|
|
 |
|
 |
send info back to server from client
why all the threads
thanks
|
|
|
|
 |
|
 |
Thanks for the code
private void OnMemuStop(object sender, System.EventArgs e)
{
tcpLsn.Stop();
tcpLsn=null;
Thread tcpThd = (Thread)threadHolder[0];
errors tcpThd.Abort();
threadHolder.Remove(0);
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll
Additional information: A blocking operation was interrupted by a call to WSACancelBlockingCall
private void OnMenuExit(object sender, System.EventArgs e)
{
errors if(fThd.IsAlive)
fThd.Abort();
if (tcpLsn!=null)
tcpLsn.Stop();
An unhandled exception of type 'System.NullReferenceException' occurred in WTcpSrv.exe
Additional information: Object reference not set to an instance of an object.
xp vs 2003
|
|
|
|
 |
|
 |
If the client and server are in different machines. Is there a way by which the server knows the IP address of the client ?
Any help will be great.
Saleem
|
|
|
|
 |
|
 |
High,
i read a message, that you worked on a socket server in C# Forms.
I need to do a socket server which communicates with up to 100 client. they exchange only a few bytes.
What i want is a Form an which i can put the communication in Listviews and store thme into the sqlserver via ado.net. Is there any sample in the www for this or parts of this?
I only find Console.Apps or the sample in codeprojct which may be not save for 24/7 working environment.
Any info ?
Thanks for your help,
christian
|
|
|
|
 |
|
 |
Implement the tcpip server and client as windows services. Then they are around all the time. I will be creating such a model in the near future; if you like I will send you the sources.
Chuck Duncan
cduncan@GuardianAngelCorp.com
|
|
|
|
 |
|
 |
Can you sendme a small sample where I use your server with a VC++ (MFC) client ?
Thanks,
Marcelo Duarte
Uruguay
|
|
|
|
 |
|
 |
Well! I have been searching for a TCP program like this. I found it. I was very happy. I also seen the message war between Ian and Jibin. I appreciate that both of them or trying to do some thing for the CSharper Community. But I feel one has to look into oneself if some one commented on one rather than just fighting back blindly. One should try to see why the other one is commenting up on some thing that one belives is the best.
Any way I learnt some thing from this article. Thanks Jibin.
I also thank Ian for bringing up some important issues out here.
Last but not the lest; Having Self confidence is good but it should not be overconfidence.
Thanks guys.
|
|
|
|
 |
|
 |
High,
i read a message, that you worked on a socket server in C# Forms.
I need to do a socket server which communicates with up to 100 client. they exchange only a few bytes.
What i want is a Form an which i can put the communication in Listviews and store thme into the sqlserver via ado.net. Is there any sample in the www for this or parts of this?
I only find Console.Apps or the sample in codeprojct which may be not save for 24/7 working environment.
Any info ?
Thanks for your help,
christian
|
|
|
|
 |
|
 |
Guys,
How can somebody call his application - "a real-time application" - if he has 'sleep' everywhere (reading from the socket, repainting listview).
It is terrible.
|
|
|
|
 |
|
 |
I don't think using sleep or reading from socket or repainting a listview makes the applikation less of realtime applikation.
Consider a movie playback program, it needs to display 25 frames per second, no more no less. This is easy for a modern computer and leaves plenty of time for sleeping, reading stuff from a socket or repaint a listview. The important thing is that the movie playback is not delayed at any time.
I'm no expert on real-time programming but I don't think that 'real-time' has anything to do with keeping the CPU busy or not updating the GUI, Just that timing of certain things is important.
The program might be terrible anyway
|
|
|
|
 |
|
 |
Even though Ian gave you a bad review. I appreciate the effort, and the fact that you created a couple examples.
Thanks again.
Ian.... if you know how to do it so well, write a better example...
|
|
|
|
 |
|
 |
Just to keep the record straight, Ian Griffiths is a name I recognized right away from O'Reilly books and his association with Chris Sells, another well known MS guru, so I'd take his criticism's with more than just a quick glance.
I'm currently developing a professional TCP/IP application and I *must* do it right the first time or it's my job. I'm using asynchronous Begin*** types of calls (BeginConnect, BeginSend, BeginRead, etc. ) rather than the synchronous calls.
I'm not using one thread per connection, since I need a scalable project. That was one of the first concepts I saw as a limit in my code. I've read Ian's ideas with interest since they may still reveal some weakness in my coding needs as I progress, though luckily I believe I've done a better job with my code.
I must agree with Ian that the application has many faults that should be fixed.
Chris A.R.
|
|
|
|
 |
|
 |
High,
i read a message, that you worked on a socket server in C# Forms.
I need to do a socket server which communicates with up to 100 client. they exchange only a few bytes.
What i want is a Form an which i can put the communication in Listviews and store thme into the sqlserver via ado.net. Is there any sample in the www for this or parts of this?
I only find Console.Apps or the sample in codeprojct which may be not save for 24/7 working environment.
Any info ?
Thanks for your help,
christian
|
|
|
|
 |
|
|
 |
|
 |
its a dll file in the sources
right click on references in the solution explorer and point to it
it worked for me
good luck
|
|
|
|
 |
|
 |
Hi,
I use Win 2000. I have client server machine. Both app were modified using your code. My server sends a message only once. The problem arises in line:
int ret = soc.Receive(receive, receive.Length, 0);
If I am not mistaken, the app should pass this line only when a message sent.
And as I said above, I send only one message and it behaves like it got more then one message.
More:in line
if(tmp.Length >0)
I added a counter in the if loop. It shows that it eneters the if condition 14 times even when the tmp.Length=null.
see that tmp.Length=null but the condition doesn't work and the app goes into the block. Am i missing something?
I posted my code here. If you don't mind to take a look and help me. 10x.
private void RecieveData()
{
int i=0;
string tmp=null;
while (true)
{
Byte[] receive = new Byte[38] ;
try
{
// Receive will block until data coming
// ret is 0 or Exception happen when Socket connection is
// broken
int ret = soc.Receive(receive, receive.Length, 0);
if (ret>0)
{
tmp = System.Text.Encoding.ASCII.GetString(receive);
if(tmp.Length >0)
{
textBox1.Text = tmp;
Thread.Sleep(100);
textBox2.Text=i.ToString();
i++;
// block until finish the UpdateListview’s job JobDone.WaitOne();
}
}
tmp=null;
}
catch (Exception e)
{
MessageBox.Show("d"+e.ToString());
/*if( !soc.Connected )
{
break;
} */
}
}
}
|
|
|
|
 |
|
 |
Forn1.resx can't be restored correctly
海纳百川,有容乃大
壁立千仞,无欲则刚
|
|
|
|
 |
|
 |
The version of listview control on the form is beat2, you can recreate it using new version. I will update it later.
Thanks
|
|
|
|
 |
|
 |
Hi, I have read your code and explications, but I have a problem here: I have only Visual C++ 6. So, can you port this app on this progr. language?
I could really use what you wrote,
Steve
|
|
|
|
 |