|
Hi to all,
I have a problem with sending data with udp and sendto function.. I'm working on a server program that has a receiver and sender thread..every thread has it's own created SOCKETs that receives/send data from/to clients (respectively) but for some reason sendto function doesn't send packets.. it returns correct value of bytes send, but no packet is on the wire (checked with the Wireshark and winPCAP).. searched for solution, but could not find anything..
can anyone know what could be error?..
|
|
|
|
|
If you're using .NET, why not use the .NET classes for this sort of stuff ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i'm not using .net, just plain old c/c++ code.. simpler than that cannot be ..
|
|
|
|
|
Well, then this is wrong forum. You can try C++/MFC instead.
|
|
|
|
|
IKoB wrote: ...plain old c/c++ code.. simpler than that cannot be
...unless you're using .NET...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I want to write an application that contacts to another application over internet.
I don't want to user a web service... because the application may send files,voic,video ,etc.
please help me.
thank you
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
What do I need to build a Tic Tac Toe game online, in which two peoples can play?
I need to learn its networking side. I mean to what extent I need to learn network programming. Where are C++/CLI tutorials available for networking? Books? Just tell me requirements for connecting the two players...
Thanks
|
|
|
|
|
Ahmed Manzoor wrote: Just tell me requirements for connecting the two players...
You can do this in several ways. If you use TCP for communication, read about socket[^] class and TCPListener[^] class.
Other way is to write a web service or WCF service where program running on two players will be communicating.
|
|
|
|
|
I don't understand all this networking jargon ...
I think I need to understand networking then go on to programming. Can you suggest any tutorials?
|
|
|
|
|
I think you should read Microsoft's documentation on sockets, you'll see that sending and receiving data over a network is really easy. You don't need to know much about networks to make your application functional.
|
|
|
|
|
I have learned networking and yet have implemented a game to be playable over network.
I don't know why you are replying to old posts
|
|
|
|
|
I am using the method which taught in <<http://www.codeproject.com/KB/office/automate_excel.aspx>> to link one of the form of the project to excel, it works.However, when I try to link another form of the same project to the excel ..it fails
It gives out the following error:
using namespace Microsoft::Office::Interop::Excel;
1>c:\users\issac\documents\visual studio 2008\projects\fyp\fyp\day.h(13) : error C3083: 'Microsoft': the symbol to the left of a '::' must be a type
1>c:\users\issac\documents\visual studio 2008\projects\fyp\fyp\day.h(13) : error C3083: 'Office': the symbol to the left of a '::' must be a type
1>c:\users\issac\documents\visual studio 2008\projects\fyp\fyp\day.h(13) : error C3083: 'Interop': the symbol to the left of a '::' must be a type
I have tried to remove the reference and add the refernce again and rebuild the solution and it still fails..Has anyone try to run the excel in two different form in the same project before? Can anyone give me some suggestion to solve it..Thanks for your kind help.
modified on Saturday, January 17, 2009 7:40 AM
|
|
|
|
|
good afternoon everybody,
i have an query regarding crystal report
i have a problem while exporting report in excel some fields are suppress when i m using following code on suppress of related fields. i m doing this to suppress duplicate data value.
WhilePrintingRecords;
stringVar MFIELD1= {ado.txt1};
BOOLEANVAR MFIELD11=FALSE;
IF MFIELD1= {ado.txt1} THEN MFIELD11:=TRUE ELSE MFIELD11:=FALSE;
MFIELD1:= {ado.txt1};
if MFIELD11 = FALSE then false else true;
pls guide me to resolve this problem
thank you
|
|
|
|
|
Hi, I'm trying to use a library which was written in C#, in my managed c++ program. To use this library in a C# program you have to use the 'using' statement.
example:
using (new LibraryObject())
{
.. do some work ..
}
Besides the namespace 'using' statement I don't think managed c++ has this statement. Is there a statement comparable to this in managed c++, or is there at least some way of going about using this library's functionality the intended way without a using statement?
Here's a link to the library: http://www.codeproject.com/KB/cpp/WaitCursor.aspx
Thanks for the help!
|
|
|
|
|
1) Implicit with C++ Stack Semantics[^]:
LibraryObject libobj;
2) Explicit with try/finally blocks:
LibraryObject^ libobj;
try
{
libobj = gcnew LibraryObject();
}
finally
{
if (libobj != nullptr)
delete libobj;
}
More info on how C++ implements disposable types...
Destructors and Finalizers in Visual C++[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
using namespace System;
using namespace System::Threading;
ref class MyThread
{
public:
static void ThreadFunc1();
static void ThreadFunc2();
};
void MyThread::ThreadFunc1()
{
Console::WriteLine("Before long sleep");
try
{
Thread::Sleep(Timeout::Infinite);
}
catch(ThreadInterruptedException^){}
Console::WriteLine("After long sleep");
}
void MyThread::ThreadFunc2()
{
for (int i = 0; i < 5; i++)
{
Console::WriteLine("Thread {0}",i.ToString());
Thread::Sleep(2);
}
}
void main()
{
Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc1));
Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc2));
Console::WriteLine("Sleep/interrupt thread");
thr1->Start();
Thread::Sleep(4);
for (int i = 0; i < 4; i++)
{
Console::WriteLine("**Main2 {0}", i.ToString());
Thread::Sleep(2);
}
thr1->Interrupt();
thr1->Join();
Console::WriteLine("\nSuspend/resume thread");
thr2->Start();
Thread::Sleep(8);
thr2->Suspend();
for (int i = 0; i < 4; i++)
{
Console::WriteLine("**Main1 {0}", i.ToString());
Thread::Sleep(2);
}
thr2->Resume();
}
This program hangs sometimes, so I'm sure there is a deadlock between the threads but I can't catch it.
It mainly stops in the code highlighted...
|
|
|
|
|
Hi,
since you are experimenting with threads I recommend you read this little series.[^]
You also are overly optimistic about timing behavior, so my timer article[^] may interest you.
|
|
|
|
|
I'm already reading a book.... May I know why it is deadlocking. I have been testing it for hours and couldn't find out the cause. Sometimes it works without any problems and sometimes it stops while running. It always throws a ThreadStateException while debugging without any breakpoints. But mainly it executes fine without debugging.
modified on Tuesday, January 13, 2009 5:44 AM
|
|
|
|
|
Hi,
you should not use Thread.Suspend/Resume, these methods are obsolete now; they serve no real purpose,
you simply can't trust them.
Furthermore Suspend can throw ThreadStateException when "The thread has not been started or is dead" as the documentation tells you; and that is what you are encountering occasionally, due to your peculiar sleep values and other system activities. Take my earlier advise.
|
|
|
|
|
Ok . I'll take your advise, but may I know what happens when a thread is sleeping and we try to suspend it? I think that's the case
|
|
|
|
|
Hi,
I do know several other Operating Systems only offer a SuspendSelf, which is obviously a synchronous operation; suspending another thread is asynchronous in nature, the caller does not know in what state the target thread is, nor how far it will continue before the suspension kicks in. This fundamental problem is why Suspend is now obsolete.
I don't know what exactly happens to a Windows or .NET thread when Suspend gets called; I never used it
since it cannot be trusted anyway.
|
|
|
|
|
I have a legacy C app which uses FFmpeg APIs.
I'm trying to update it, I want to write a UI in C# and keep the core in C.
So, i'm dabbling in C++/CLI for the first time.
It's my understanding that I can create a managed class wrapper, and have managed methods which take managed parameters, convert them as necessary to unmanaged equivalents (with System.Runtime.InteropServices.Marshal methods), do the work in native C, and then convert outputs from unmanaged to managed types for return.
However, I'm stuck at the start. I've created a class like this:-
ref class FFmpegCap
{
public:
FFmpegCap(String^ inputVideo);
protected:
AVFormatContext *m_pFormatContext;
};
In my constructor, i need to call a C FFmpeg function to initialise the library, one of the parameters it requires is of type AVFormatContext ** . So, I call this function as follows:-
if (av_open_input_file(&m_pFormatContext, pInputVideo ,NULL,0,NULL) != 0)
{
}
However, this fails to compile; error C2664: 'av_open_input_file' : cannot convert parameter 1 from 'cli::interior_ptr<type>' to 'AVFormatContext **'
It seems that the & operator is not doing what I expect of it!
Any pointers?
Thanks
Jon
|
|
|
|
|
|
The thing that confuses me is that &m_pFormatContext should be an unmanaged pointer, therefore AFAIU shouldn't need pinning?
|
|
|
|
|
Your unmanaged pointer is inside a managed object. You need pin_ptr to prevent the unmanaged pointer pointing to different location during the garbage collection.
Have you tried changing to pin_ptr? I believe that should solve the issue.
|
|
|
|