Not connected to a server
I used Lacewing C++ library to create my server and client with MFC and found the client can't connect to the localhost server.
server side
Lacewing::Server myServer;
......
myServer.RegisterHandlerSetName(HandlerSetName);
myServer.Host(9121);
bool bHosting = myServer.Hosting();
int pot = myServer.Port();
It seems working well
client side
Lacewing::Client myClient;
......
myClient.RegisterHandlerChannelListComplete(Handle rChannelListComplete);
myClient.Connect("localhost", 9121);
const char* ip = myClient.ServerIP();
int port = myClient.ServerPort();
I got the empty ip and -1 port.
What's wrong with it? I missed something?
Re: Not connected to a server
Connect() isn't blocking. You need to register the connect handler and wait for that.
Re: Not connected to a server
Quote:
Originally Posted by Jamie
Connect() isn't blocking. You need to register the connect handler and wait for that.
Thanks Jamie.
But I came across the another problem. When I get an error in error handler, I want to iterate error code like the following,
for(int ID = Error.ErrorCodeLoop(); ID; ID = Error.ErrorCodeLoop(ID))
{
Lacewing::ErrorCode::Type ErrorCode = Error.ErrorCodeLoopIndex(ID);
// cout << "Error: " << Lacewing::ErrorCode::ToString(ErrorCode) << endl;
}
But I got link errors
1>*****.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum Lacewing::ErrorCode::Type __thiscall Lacewing::Error::ErrorCodeLoopIndex(int)" (__imp_?ErrorCodeLoopIndex@Error@Lacewing@@QAE?AW4 Type@ErrorCode@2@H@Z) referenced in function "void __cdecl HandlerError(class Lacewing::Client &,class Lacewing::Error &)" (?HandlerError@@YAXAAVClient@Lacewing@@AAVError@2@ @Z)
1>*****.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall Lacewing::Error::ErrorCodeLoop(int)" (__imp_?ErrorCodeLoop@Error@Lacewing@@QAEHH@Z) referenced in function "void __cdecl HandlerError(class Lacewing::Client &,class Lacewing::Error &)" (?HandlerError@@YAXAAVClient@Lacewing@@AAVError@2@ @Z)
I am not sure whether the two functions correctly exported in the library, since no linking error for Error.ToString()
One more question,
in class Client, Send a file to the server,
LacewingFunction File * SendFile(int Subchannel, const char * Filename);
Could you explain what the parameter Subchannel is? And How do I set it?
Please forgive me for the silly questions, I am a newbie here.
Thank you in advance again.
Re: Not connected to a server
Ah, you're right, looks like I didn't export them. Error.ToString() gives you a string representation of the entire error (it loops through itself) so you might be alright with that for now.
That SendFile function in the Client class shouldn't even be there - the Lacewing protocol has no mechanism for file transfer. The only way to send a file currently is to send it in chunks with Send().
By the way - there's a big update coming to the C++ library soon (Q1 2011), and the library is also going open source.
Re: Not connected to a server
Regarding Send in class Client, what the maximum size can it send at a time?
Looking forward to the new release.
Re: Not connected to a server
One more question, I found when the client software crash and offline accidentally, the server doesn't trigger the disconnect handler. Should I create a timer on server to send ping to the client to make sure the client connected?
Re: Not connected to a server
Quote:
Originally Posted by Ziyoo
Regarding Send in class Client, what the maximum size can it send at a time?
Looking forward to the new release.
Hmm, I wouldn't try sending more than 60 KB in the current build.
Quote:
Originally Posted by Ziyoo
One more question, I found when the client software crash and offline accidentally, the server doesn't trigger the disconnect handler. Should I create a timer on server to send ping to the client to make sure the client connected?
It's meant to do that automatically - it definitely does in the new build. I guess sending them yourself is an acceptable workaround for now, yes.
Re: Not connected to a server
Quote:
Originally Posted by Jamie
it definitely does in the new build.
By "new" you mean 18 or 17?
Re: Not connected to a server
Re: Not connected to a server
I'm getting this problem, too... If client stays idle for something about 5 minutes the server doesn't trigger the disconnect handler and after that the server stops working, just nobody can join...
I have my server as a console app in Visual C++ 2010. Could somebody help me and tell me how to create an event or something what would ping each client every few minutes?