|
The socket is innocent, seems like it was my fault at another part of the code. Anyway, the problem is solved. Thank you very much for your reply.
|
|
|
|
|
May I know what the problem was?
ty
|
|
|
|
|
I have inserted the mschart into window form of visual c++ 2008, but there is very little articles talking about how to use it in c++ , does anyone know how to use it?Thanks.
|
|
|
|
|
Here[^] is a C# implementation. Converting that to C++/CLI will be trivial.
|
|
|
|
|
I have a CLR Application where I am trying to write a .NET wrapper over calls made to native C++ Library. I am using VS 2008 but libraries are compiled in VS2003 or 2005. I am getting some linker errors on linking. Strangely, every error is 1 of these 3 unresolved external symbol ones -
1. std::locale::facet::_Register
2. std::ctype&::_Getcat
3. std::strstream::strstream
Details of the errors -
error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall std::strstream::~strstream(void)" (__imp_??1strstream@std@@UAE@XZ)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::locale::facet::_Register(void)" (__imp_?_Register@facet@locale@std@@QAEXXZ)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::locale::facet::_Register(void)" (__imp_?_Register@facet@locale@std@@QAEXXZ)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::ctype<char>::_Getcat(class std::locale::facet const * *)" (__imp_?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::ctype<char>::_Getcat(class std::locale::facet const * *)" (__imp_?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::ctype<unsigned short>::_Getcat(class std::locale::facet const * *)" (__imp_?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::ctype<unsigned short>::_Getcat(class std::locale::facet const * *)" (__imp_?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::strstream::strstream(char *,int,int)" (__imp_??0strstream@std@@QAE@PADHH@Z)
Thanks a lot for the help.
Amit
|
|
|
|
|
I'm getting a few errors while creating a new thread, I don't know what am I doing wrong but somethings not working properly in the Thread creation in the above code.
#include "stdafx.h"
using namespace System;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::IO;
using namespace System::Threading;
using namespace System::Collections;
using namespace System::Text;
ref class ClientHandler
{
public:
TcpClient^ clientSocket;
void RunClient()
{
StreamReader^ readerStream = gcnew StreamReader(clientSocket->GetStream());
NetworkStream^ writerStream = clientSocket->GetStream();
String^ returnData = readerStream->ReadLine();
String^ userName = returnData;
Console::WriteLine("Welcome " + userName + " to the Server");
while (true)
{
returnData = readerStream->ReadLine();
if (returnData->IndexOf("QUIT") > -1)
{
Console::WriteLine("Bye Bye " + userName);
break;
}
Console::WriteLine(userName + ": " + returnData);
returnData += "\r\n";
array<byte>^ dataWrite = Encoding::ASCII->GetBytes(returnData);
writerStream->Write(dataWrite, 0, dataWrite->Length);
}
clientSocket->Close();
}
};
const int ECHO_PORT = 8080;
void main(void)
{
try
{
TcpListener^ clientListener = gcnew TcpListener(ECHO_PORT);
clientListener->Start();
Console::WriteLine("Waiting for connections...");
while (true)
{
TcpClient^ client = clientListener->AcceptTcpClient();
ClientHandler^ cHandler = gcnew ClientHandler();
cHandler->clientSocket = client;
Thread^ clientThread = gcnew Thread(gcnew ThreadStart(cHandler, &cHandler::RunClient));
clientThread->Start();
}
clientListener->Stop();
}
catch (Exception^ e)
{
Console::WriteLine("Exception: " + e);
}
}</byte>
Here are the errors I'm getting
1>.\ThreadedServer.cpp(57) : warning C4947: 'System::Net::Sockets::TcpListener::TcpListener' : marked as obsolete
1> Message: 'This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port) instead.
1>.\ThreadedServer.cpp(74) : error C2825: 'cHandler': must be a class or namespace when followed by '::'
1>.\ThreadedServer.cpp(74) : error C2039: 'RunClient' : is not a member of '`global namespace''
1>.\ThreadedServer.cpp(74) : error C2146: syntax error : missing ')' before identifier 'RunClient'
1>.\ThreadedServer.cpp(74) : error C3924: error in argument #2 of delegate
constructor call 'System::Threading::ThreadStart':
1> pointer to member function expected
1>.\ThreadedServer.cpp(74) : error C2146: syntax error : missing ')' before identifier 'RunClient'
1>.\ThreadedServer.cpp(74) : error C2146: syntax error : missing ';' before identifier 'RunClient'
1>.\ThreadedServer.cpp(74) : error C2059: syntax error : ')'
1>.\ThreadedServer.cpp(74) : error C2059: syntax error : ')'
1>.\ThreadedServer.cpp(74) : error C2065: 'RunClient' : undeclared identifier
Any hints will be really appreciated
|
|
|
|
|
try this
Thread^ clientThread = gcnew Thread(gcnew ThreadStart(cHandler, &ClientHandler::RunClient));
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Cool, you just proved that I'm e n00b.
I don't know how but I looked over that line a hundred of times and still couldn't figure it out.
Whatever, problem's solved....
|
|
|
|
|
i want to create a file at the application path, i.e where my exe is located, but i am not finding any ways of determining the app path.can any one help
thanks well in advance
Naveen
|
|
|
|
|
Application.ExecutablePath or Application.StartupPath
|
|
|
|
|
Thanks a lot, its working fine now
Naveen
|
|
|
|
|
How to send a serialized object to the networkstream?
In the serialize method of binaryformatter, if I pass to first the parameter a NetworkStream object? what will happen?
I want to send a serialized object from a server to client...
|
|
|
|
|
Ahmed Manzoor wrote: In the serialize method of binaryformatter, if I pass to first the parameter a NetworkStream object? what will happen?
The bytes will be sent across the connection. Somehow I doubt that helps you. Perhaps you want to ask a more specific question?
led mike
|
|
|
|
|
How will the bytes be sent across the connection?
I get a NetworkStream from the GetStream method from the TcpClient object, then I serialize an object to the NetworkStreamwhich I received using BinaryFormatter.
1) Will the serialization happen properly?
2) If it does, how to get that object then which is serialized, how is deserialization gonna happen on the client side?
modified on Thursday, January 22, 2009 2:10 PM
|
|
|
|
|
Ahmed Manzoor wrote: how is deserialization gonna happen on the client side?
Are you just winging this? I strongly suggest not doing that. One should prefer to introduce themselves to the Serialization topic by reading one or more of the many Many articles available on the subject. Try some of these.[^]
led mike
|
|
|
|
|
What winging? I know how to serialize to File streams, but I'm not sure if it is done the same way with Network streams.
I need to know how to deserialize the object on the client side when it is serialized on the server side first. Is it the same as serializing to a File stream?
Rather than giving articles on serialization you shall suggest me articles with serializing over networks.
Help !!!
modified on Friday, January 23, 2009 6:32 AM
|
|
|
|
|
Ahmed Manzoor wrote: I know how to serialize to File streams
Do you know how to Deserialize them from Files? If not you need to read the subjects I suggested. If you do then it's the same thing.
led mike
|
|
|
|
|
Lol, Thanks then. I'm going to try if it works properly then get back to you.
|
|
|
|
|
i am trying to write a small window form application. I use a file dialog to select a file in my computer. However, in the debug mode, when pressing the browse button, i got this error message :
"An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll
Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
This problem happen only when i try to create a object of a class in the Form1.h file. If i delete the code of creating object, everything goes fine.
I have checked the main function, it already had [STAThreadAttribute] marked on it. So, can you give me any suggestion, please? thanks
|
|
|
|
|
You must set the Apartment state of the thread, to be STA ( Single Threaded Apartment ) to work with OLE.
// Run application Thread
Thread _threadAppProcessor = new Thread(new ThreadStart(StartThread));
_threadAppProcessor.SetApartmentState(ApartmentState.STA);
_threadAppProcessor.Start();
|
|
|
|
|
Hi,
How to use T-Sql in Sql server 2005,bec i'm new to it plz plz help me out.
With Regards
Mahesh
|
|
|
|
|
Welcome to CodeProject
You are using an improper forum for your question. Please read the first message in this forum as it explains what the purpose of this forum is. Try asking a Database programming question in the Database Forum[^].
Also don't repost your questions. To get the most out of this site you should take some time to read some of it and get the idea of how it works. Otherwise you might just be irritating people to the point where no one will help you.
CodeProject Forum Guidelines[^]
led mike
|
|
|
|
|
Hi,
How to use T-Sql in Sql server 2005,bec i'm new to it plz plz help me out.
With Regards
Mahesh
|
|
|
|
|
Sorry, I want to display an video media file in window form application of visual c++ 2008,but I have no idea how to make it?Is it possible .And if it is yes,can anyone tell me how to do.Thanks.
modified on Wednesday, January 21, 2009 9:35 AM
|
|
|
|
|
If the media is something Windows Media Player can play, you could use
the Windows Media Player control:
Using Windows Media Player with .NET[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|