|
Try referring the following links:
http://blogs.msdn.com/shawnfa/archive/2006/07/15/665763.aspx
http://msdn2.microsoft.com/en-us/library/ms228998.aspx
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Hello.
Im doing a client server program where the client program is created using Visual C++.NET meanwhile the server program is created using C#.NET. Just for my own knowledge, can both of these program be connected via a network using TCP protocol. I tried to execute the sample. there was no error but it could not be connected. Which part that must i edit? Is it ok if i only edit the client part (created using C++). This is because the server part also have multithreading mechanism, so i dont want to mess that up. For your information, i tried to connect both client and server using port 5000. I will also include here the connection part of the client and server source code. Did i miss anything in the source code in the code snippet attachment? Thank you and your help is very appreciated.
<br />
<br />
<br />
<br />
InitWSA();<br />
<br />
sock = socket(AF_INET, SOCK_STREAM, 0);<br />
if (sock < 0) {<br />
printf("Error no %d occured when creating socket\n", errno);<br />
exit(-1);<br />
}<br />
<br />
myaddr.sin_family = AF_INET;<br />
myaddr.sin_port = 5001;<br />
myaddr.sin_addr.s_addr = INADDR_ANY;<br />
<br />
status = bind(sock, (struct sockaddr *)&myaddr, sizeof(struct sockaddr));<br />
if(status < 0) {<br />
printf("Error no %d occured when binding\n", errno);<br />
exit(-1);<br />
}<br />
<br />
<br />
receiver.sin_family = AF_INET;<br />
receiver.sin_port = 5000;<br />
receiver.sin_addr.s_addr = inet_addr("127.0.0.1");<br />
<br />
status = connect(sock, (struct sockaddr *)&receiver, sizeof(struct sockaddr));<br />
if (status < 0) {<br />
printf("Cannot connect to server, error no %d occured\n", errno);
exit(-1);<br />
}<br />
<br />
<br />
<br />
<br />
<br />
string portStr = textBoxPort.Text;
int port = System.Convert.ToInt32(portStr);<br />
<br />
<br />
m_mainSocket = new Socke(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);<br />
IPEndPoint ipLocal = new IPEndPoint (IPAddress.Any, port);<br />
<br />
<br />
m_mainSocket.Bind( ipLocal );<br />
<br />
<br />
m_mainSocket.Listen(4);<br />
<br />
<br />
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
<br />
UpdateControls(true);<br />
<br />
<br />
<br />
|
|
|
|
|
Maybe try NOT binding the client socket - let the protocol pick the socket name.
You should be able to debug this easily.
What calls are failing?
On the client, I don't see any code that checks error codes returned from failed socket API calls
Shouldn't you be using WSAGetLastError instead of errno?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hello and thanks for the reply
I tried the method you said. So I disable the binding socket. Still, the client could not connect to the server. Actually, there is no error in the code but it just could not connect the client which is programmed in C meanwhile the server side is programmed using C#. So i think it is not about the errno or the WSAGetLastError problem. Actually, this is just only a test program. After i proved that it can connect, then I will produce a real version. I just want to know is there any method or code which can connect a client programmed in C to a server which is programmed in C#. I assume that the connect() call failed since the printf("Cannot connect to server, error no %d occured\n", errno); as in the code snippet will be displayed. So this clearly means that it just could not connect to the server. Anyway, thank for your reply and help. Any other idea's or solution? hehe..
|
|
|
|
|
Kogee San wrote: I just want to know is there any method or code which can connect a client programmed in C to a server which is programmed in C#
TCP/IP is TCP/IP, no matter what platform it runs on or what language the code is written in.
Why do you dismiss error codes? They can give you important clues to reasons for failure.
That's why they are there. Why not use the clues the system offers? Otherwise all you can do is guess.
Using the socket APIs properly will help...
First you need the port number in network byte order:
receiver.sin_port = <span style="font-weight: bold;">htons(5000)</span>;
Then you need to properly check for errors:
status = connect(sock, (struct sockaddr *)&receiver, sizeof(struct sockaddr));<br />
<br />
if (<span style="font-weight: bold;">SOCKET_ERROR</span> == status)<br />
{<br />
printf("Cannot connect to server, error no %d occured\n", ::WSAGetLastError() );
<br />
}<br />
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hello mark
Thanks for the reply. I just add the byte order method htons and it works. Thanks for the solution. I really2 appreciated it. Also thanks for the tips to take error messages seriously. I will take your advice. I know error messages is important for debugging, but i just consider a simple connection from client/server, thats why i dont want to concern the error messages. I will be careful next time. Thanks again.
|
|
|
|
|
plz how i can do tihs text""hello word tsdi" move with vb.net timer
thikns so mutch
|
|
|
|
|
Hi,
1.
have a Windows.Forms.Timer tick at the required frequency; in its Tick handler:
2.
modify the text you want to show, and cause a repaint.
say you are using a Label, just set the new string value in label.Text
say you are drawing the string yourself in a Panel's OnPaint method, call panel.Invalidate().
etc.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I created an Service and when i tried installing it to Services through dos I get the following error.
"No public installers with the RunInstallerAttribute.Yes attribute could be found..."
any ideas on sorting this out?
|
|
|
|
|
You don't have this:
[RunInstaller(true)] <--------------------
public partial class MyInstaller : Installer
and your installer class has to be public.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
thanks,
but i had both of those... anything else?
i followed the steps from ths msdn forums
|
|
|
|
|
Hi,
I have added an column to the typed dataset from .xsd file schema. But when i check it in the debug mode, I see that column field mapping for 2-3 has been mismatched.
What order do I need to add the field in to the .xsd schema file?
I possible can any body let me know the process to add an column in existing typed dataset?
Regards,
Vipul Mehta
|
|
|
|
|
I've written an assembly (.Net 2.0 DLL in C#) that streams a FLV video file to a flash player contained in the same program. Due to the nature of the FLV file, I have to load it in small chunks and pass the chunks in the stream one at a time. This works pretty well. However...
Under Vista (not SP1), as the file is streamed, memory consumption creeps up and up and up, and even after the stream has been closed, the memory consumption keeps increasing until the program itself is shutdown. Under XP, this does not happen at all. We have almost verified that the flash player is probably the culprit, but we don't know what to do about it.
We've tried streaming larger and smaller blocks of data, we've completely re-written the threading code twice, and we've tried several methods for actually streaming the data.
Can anyone offer any advice or pointers? Something to look for?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
How are you accurately checking memory usage?
Vista caches memory much different than previous operating systems.
Vista will happily use up all the RAM before dropping it for other processes to use.
Of course, there very well could be a bug in the player
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well, it's not real scientific - we use Task Manager.
Yeah, I'm aware that Vista uses memory differently, but the behavior I've described starts to adversely affect the program's performance because eventually, Vista starts paging to disk to accommodate it's "caching" mechanism. On REALLY long videos (we're talking 1gb or more) the video develops a real bad stutter, and any system performance that escapes Vista's resource usage essentially disappears.
To read a block of the file at a time, I allocate an array of bytes before the loop, and I re-use that array until the operation is done. To make sure we didn't have a leak in the loop code, we simply stopped streaming what we were reading, and just let the loop load block after block of data. The memory use didn't go up at all at that point. This tells me that the problem is in the player. However, we don't have the source to the player itself. I think it's Adobe's component, but I'm not sure. I did the encryption and file streaming part of the app and haven't had to deal with "the other end" of things.
Is there a utility that will track memory usage better than Task Manager?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Is there a utility that will track memory usage better than Task Manager?
that's rhetoric I trust.
I usually have a timer (Windows.Forms.Timer) that periodically (1Hz) updates some numbers
in the GUI (a statusbar label); I look at:
Environment.WorkingSet for memory leaks,
GetGuiResources(processHandle, 0) for missing Dispose() calls on GDI objects,
etc.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
In addition to the other comments...
I don't think I have to tell you, that sounds like a memory leak bug to me.
If you've eliminated the possible causes in your code then it's the player.
You know that already
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What version of Flash Player? There are issues with older versions.
|
|
|
|
|
I believe we even tried the latest one, and it still does it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Have you profiled your app? It's useful to do this with a utility like CLR Profiler.
|
|
|
|
|
Have you tried using ProcessXP ^ by Sysinternals or Perfmon?
|
|
|
|
|
The CLR Profiler is incredibly useful for this. If the CLR GC itself is not continually allocating more and more memory, the problem is not your app - it's the FLV player, as you seem to already expect.
I'm curious why you're seeing that though. I don't seem to have that problem when I'm watching an FLV using FLV Player, for instance, or when I'm watching things in my browser. This is one of those things that I would absolutely not expect to see in a commercial, widely released, widely used product - simply because I'd expect the bugs to be solved long, long ago.
I wonder if there's not some sort of cleanup or clear function in the player you should be calling after every data pass.
Curious: Does the increase in memory consumption seem to match the amount of data you're sending to the player (decoded, of course)? That is, if you're sending it a 1KB chunk of FLV data, does the amount of decoded data correspond to the increase in memory usage by the OS?
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
Hello,
I have a solution and it has 2 projects. When I try to open a project it says:
"The project type is not supported by the installation."
I have VS 2005 with framewotk 2.0
Any suggestions what might be wrong?
Regards,
Pavas
Regards,
Pavas
modified on Thursday, April 3, 2008 7:59 PM
|
|
|
|
|
Hi,
Maybe this will help.[^]
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks.
If I have there are some custom controls installed and there are version difference in the framework like one project in 1.1 and other in 2.0..
Will this case Issue...
Regards,
Pavas
|
|
|
|