|
Did you replace CSocket by CCeSocket?
|
|
|
|
|
Yes,I've tried that. Apparently Csocket is still supported in WinCE embedded visual C++ according to MSDN. So I tried out both ways. However the same error still occurs.
This are errors I got...main source is 1st error.
ERRORS WHILE COMPLIING
-----------------------
:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(60) : error C2065: 'AFX_MODULE_STATE' : undeclared identifier
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(60) : error C2065: 'pModuleState' : undeclared identifier
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(60) : error C2065: 'AfxGetModuleState' : undeclared identifier
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(60) : error C2106: '=' : left operand must be l-value
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(61) : error C2227: left of '->m_pClassInit' must point to class/struct/union
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(61) : error C2227: left of '->m_classList' must point to class/struct/union
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(63) : error C2227: left of '->m_pFactoryInit' must point to class/struct/union
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(63) : error C2227: left of '->m_factoryList' must point to class/struct/union
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(65) : error C2227: left of '->m_classList' must point to class/struct/union
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(65) : error C2228: left of '.m_pHead' must have class/struct/union type
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(67) : error C2227: left of '->m_factoryList' must point to class/struct/union
C:\windows ce tools\wce300\Pocket PC 2002\mfc\include\afxdllx.h(67) : error C2228: left of '.m_pHead' must have class/struct/union type
C:\Documents and Settings\Vetronics\Desktop\NDK\NDK.cpp(14) : error C2146: syntax error : missing ';' before identifier 'NDKDLL'
C:\Documents and Settings\Vetronics\Desktop\NDK\NDK.cpp(14) : fatal error C1004: unexpected end of file found
Error executing clarm.exe.
NDK.dll - 14 error(s), 0 warning(s)
Thanx for the swift reply.
Yap Ing Looi
Singapore
|
|
|
|
|
Try that, copy all NDK files into your project. Don't use the DLL project.
|
|
|
|
|
Hi, I've managed to create the NDK dll(without the Chat Server or Chat Client exe files). Problem here is that when I try to register the dll in pocket pc 2002, it gives me the following error :
"ndk.dll was loaded, but the dllregisterserver entry point was not found.
DllRegisterServer may not be exported, or a corrupt version of ndk.dll may be in memory. Consider using PView to detect and remove it."
The reason I need the dll is that I am trying to use the same structure for NDKmessages to link with my server PC. However, my client application is VB Based and although I can link using VB, I need the NDK format. thus I tried porting the dll over.
However I'm still unable to use this route...any suggestions?
thanx.
Regards
Yap Ing Looi
Singapore
|
|
|
|
|
Hi, just tried directly calling the dll without registering it, but it seems that the application is unable to load function.
2 errors are given:
Unable to load function or
Invalid Procedure Call or Argument.
IngLooi
Singapore
|
|
|
|
|
The DLL does not need to be registered.
I don't think that you can load the CNDKMessage class in VB.
In VB, you can call standard function from a DLL but you cannot call method of a class. That's what I think.
|
|
|
|
|
Hi Everyone
I am developing a server based chat application , there is also a direct client to client file transfer , just MSN File Transfer.
This is easy when two parties are directly connected to internet with dial up in this case they both will have unique ip.But the problem is if supose one client is using internet with LAN sharing and other is connected to internet through dial up then , so for the first one we can only get the ip adress assigned to net server to which we are connected with internet , not the machine which is connected with it through LAN , so no direct client to client connection.
But i know MSN messenger is doing it so there must be some way doing this . CAN SOMEONE HELP ME ABOUT THIS
|
|
|
|
|
It's simple ! Use direct connected machine as the server and do server-to-client transfer..
|
|
|
|
|
I don't know "How you can transfer files between Client-server on LAN" it take my 6 weeks.
Please help me
Thanks
|
|
|
|
|
Hi,
when using the client and the server on one PC with sending many, many request to the server the PC gets memory problems. I used the sample program for the NDK and modify only the client:
OnButtonSend()
{
for(;;)
SentMessageToServer(message);
}
Memory usage is increasing. What can I do?
Any ideas what is going wrong?
|
|
|
|
|
Buy more Memories!
Windows keeps all buffers until the server process all messages.
|
|
|
|
|
How can i change the Connection from TCP to UDP?
|
|
|
|
|
In the method Create of CSocket uses the define SOCK_DGRAM
|
|
|
|
|
Thanks
|
|
|
|
|
In both OnReceive() functions in NDKClientSocket.cpp and NDKServerSocket.cpp I added these lines:
// Called when data is received.
void CNDKClientSocket::OnReceive(int nErrorCode)
{
CString str;
UINT ui;
//remove read notifications
VERIFY(AsyncSelect(/*FD_READ | */FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE));
...
//reset notifications to default
if(0 != GetSockName(str, ui))
{
VERIFY(AsyncSelect());
}
}
I was having problems with the ASyncSelect being fired even if the socket had been deleted because of a termination of a connection. In my game (http://www.settlers3d.net) this was showing up as people having problems with the game crashing after they had played one game and then tried to connect to another. I couldn't figure out a great way to resolve this, but adding the GetSockName() call seems to work because this CAsyncSocket function call seems to still be valid even if the socket has been deleted and it returns 0. Others may have a better solution, but I posted this to at least get some feedback on it, and perhaps someone else will think of a better way.
|
|
|
|
|
Such fix already was posted. It not solution. Cause we lose about 90% of speed.
|
|
|
|
|
With my initial protoco design, I have been passing data via the primitive data field types (strings, int's, etc). The basic logic flow requires me to:
1) Deconstruct the object and assemble the varying field values into a CNDKMessage.
2) Send that message to the server and reconstruct the object on the server side.
3) Do some processing.
4) Deconstruct the object again assembling its different values into a CNDMessage and send it back to the client.
5) The client then takes the message fields and recontructs the object with the new values.
<sigh>
I have been looking at the CNDKMessage that will allow me to pass an entire send an entire object (LPVOID,UINT size).
This would make it much more convenient to just send the entire object without having to compose/decompose it's primitive elements.
I don't see any troubles with this. But am I missing some design considerations here? The only one that I can think of is that this may cause troubles when producing a cross-platform client.
How does everyone else generally do it? Do you usually just send the entire object, or do you decompose your protocol into primitive types of integers and strings?
Thanks in advance.
Jim
QTExtender - The OFFICIAL addon for QuoteTracker.
|
|
|
|
|
I decompose the message into primitive types.
Sébastien
|
|
|
|
|
Hi Sébastien,
Is there a way to get the OnIsConnectionAccepted() function to behave in the same fashion as if the server were not running?
If I return FALSE, the clients still appear to connect but they cannot send or receive messages and in some cases, using the GetNbUsers() function to limit the number of users has caused my server to crash.
Any ideas?
Thanks,
Don
|
|
|
|
|
Hi,
Please remove the line ASSERT(GetNbUsers()) in the method OnIsConnectionAccepted.
It should work now.
Sébastien
|
|
|
|
|
Hi Sebastien,
Thanks for getting back to me. Unfortunately, I'd already tried that. All I use doing in the OnIsConnectionAccepted method was the following:
if (GetNbUsers() > LicenseCount)
return FALSE;
else
return TRUE;
Fortunately, I found a better way to accomplish the license limit. I always return TRUE in the above method and go ahead and let them connect, then I test the number of users in the OnMessage method when they've joined. If they've exceeded the license limit, the server sends them back a license error message and the client informs the user, does a CloseConnection(), an OnTimer event is started, and it will attempt to reconnect in x milliseconds (defined in a registry setting).
This gives me a little more control over what's displayed to the user on the client side, and the administrator on the server side, where I can use the AddSystemText method to display what just happened. It shows that the user attempted to connect, but that only x number of users are able to connected with this particular license, then lets the admin know that it'll be disconnected, and then you see the user leaving the server. It all happens within a fraction of a second of course, but it's perfect for what I was trying to accomplish.
I'm not sure why the OnIsConnectionAccepted() method wasn't working. Probably something I've done. Anyway, thanks again for this great class!
Cheers,
Don
|
|
|
|
|
hi everybody! (hi doctor nick! )
ok, herez the thing.. i'm working in MFC for one year, but i've never worked with sockets yet (except with VB, which is kinda gaay..JK ).
i'm planning to make an instant messenger on this concept:
app consisting of server and clients. server accepts new connections, establishes a new connection with the requesting socket and voilá - chat. also, when my users want to connect to somebody's server, program creates a new socket and voilá - chat. so, herez how i immagined it, but i seem to have no ideas how to implement this , and now i'm hoping someone here will help me with those ideas..
user is able to exchange messages with many users at the same time, but they talk separately.(like...icq, msn, yahoo messenger..). each connection should have its own dialog, with separate properties. there is a main dialog which would basically organize everything (accepting connections, taking care of the existing ones, cleaning up when shutting down, holding contacts..).
and that's just basic stuff. how do i search the net for online users?? if a user wants to search for his frend, how do you that? and do i search by machine name or...HOW...!?!?
I'd just like to say that i'm not asking for the code (not jet )), just for the concepts how this is done. i've never done anything like this, and i'm clueless..
oh and, thanx everybody, this site has a GREAT community..
t1
---
kick ash.
http://t1tan.cjb.net
|
|
|
|
|
Hi t1,
I was in your shoes about six months ago, still don't know dookie about client/server winsocks and such, but this class will definately send you in the right direction, if nothing else.
My advice is to take a little time and play with the demo. Everything is documented pretty well and you should be able to do all of the things that you mentioned here.
I believe someone had asked the question in one of these previous posts on how to get the list of users to a client, and the answer was to put them into an array and send it back to the client from the server. You'll have to see the post for more information on that question in particular, but basically, your client would send a message to the server containing the users name that you're seeking (or request the complete list if you wish), and then the server could look up the name and return a TRUE or FALSE (or whatever you want) letting you know whether the user is connected or not.
You could also set up new messages to be shared between the client and server, in which the client would tell the server which userid to send the message to, and then the server would simply take the message apart, see who it's supposed to go to, put it back together, and send it to that user, and vice versa. If the user isn't connected, the server could send a message back to the requestor letting them know.
One thing to note (something that got me) is that the messages you define have to be in order and identical on both sides in ChatMessage.h (in your client and server). I was banging my head against the wall for a few days with this one, until it dawned on me.
Hope this helps, or at least encourages you to press on. It's a little intimidating at first but if you take a little time and familiarize yourself with the NDK functions above, you'll be chatting and winsocking in no time!
Cheers,
Don
|
|
|
|
|
everything's kewl, except for one thing: i was planning to make a peer-to-peer app, so there should be no central server at all. that's when i get into trouble of getting the "online users list" - where to get it from?? how do the programs like kazaa & winmx do it? (as far as i know they don't have any server??) and how do you manage everything (dis)connections if there is no server?? and how to connect two "clients" (i.e. no real server)?
thanx for the rest of the tips, i'm sure they will prove usefull
there is one more thing i could ask here.. if i create a dialog resource, and inherit it from CNDKServer/CNDKClient, is that more practical then creating a public varible of the same dialog class??
that's it, i've already said too much ...
tnx
t1.
---
kick ash.
http://t1tan.cjb.net
|
|
|
|
|
Well, I'm mostly guessing and basing a little on experience, as I haven't seen the Kazaa code, but I imagine that the applications are acting as both clients and servers.
Peer-to-peer usually occurs by specifying a specific computer to communicate with, in which case you would need to know the IP address or the hostname of the computer you're calling. When you make the request, it'll send a packet to that computer to see if it's listening. If so, the computer sends back an acknowledgement and the connection is established. This all happens on a port that is specific to the application.
It looks like Kazaa and these other chat-type programs operate a little differently, where they don't know the IP address or hostname of the computer they're calling, so they more or less broadcast the request by enumerating IP addresses and attempt to locate the applications that way.
In Kazaa's case for example, and again, just by what little I've read on their website about Supernodes and such, it sounds like when you install the application, it detects if you have a high speed Internet connection. If so, the "server" part of your application is probably enabled and your application will listen on a predefined winsock port, as well as send connection requests, and will store a list of connected users and local files that it finds.
As others start up in your area, they'll do the same thing and ask you for a list of your users, and so on.
When you start the application the first time, it most likely enumerates a list of TCP/IP addresses from your ISP's local routing tables, and then it starts listening for new connections and sends out a request to all of those IP addresses on a specific port (1214 in Kazaa's case) to see if there are other Kazaa applications listening at those IP addresses. If so, it'll update it's user/file list with the user/file list of that computer and move on to the next one, until it eventually has a fairly complete list.
It's works in sort of the same fashion as broadcasting, except that it's using TCP/IP instead of netbios, which makes it a little more reliable. Chances are, it probably has its own host table as well, where it stores IP addresses (in a flat file or something) on your local computer of other Kazaa "Supernodes" that it's found in the past. So the next time you start it up, it'll send a request directly to those IP addresses first, and then attempt to look for others.
As more Kazaa applications start up across the Internet, the host tables in the routers will naturally keep the routes alive so other Kazaa applications can find each other more quickly and easily.
When you do a search for a specific user that's not already in your user list, it sounds like it'll go out and ask those other Kazaa Supernodes if they've heard of them until it finds one that has, which then checks to see if they're online. The request is probably passed off to other Kazaa applications as the routes get longer, and they'll continue to look for the user while your Kazaa application is simply waiting for acknowledgements.
In other words, say you're located in Los Angeles and you're looking for a user in New York. First, your application will look for the user locally, asking all of the Kazaa applications in Los Angeles first, then spreading out. Then those applications will also send out the request and where it came from (you) so it knows how to let you know when the user is found. Eventually, you'll have searched all over California, then Arizona, Nevada, and so on, until it reaches its way to New York and finds the user or times out, whichever comes first.
When that happens of course, you've just opened up a whole new world of routes to Kazaa applications for yourself and those around you, thus it won't take long before all of the Kazaa applications know of each other's existence. As it becomes more widely used, it learns of more and more applications within your area and will know how to find them quicker the next time.
Routers are set up so that they'll first attempt to route you to shorter distances (the path of least resistance) by associating costs with the lines to which they're connected.
It sounds like it would be a very long process, but we're only talking milliseconds here, considering all of the Supernodes are running with broadband connections.
If you've ever worked with domain controllers, they have a similar logic, where periodically inform the other domain controllers of users who've logged onto a domain or logged off. It's a synchronization process that occurs roughly every 15 minutes by default.
It's sort of like spreading rumors. When you connect/disconnect, you tell those around you, they tell their friends, their friends tell their friends, and so on and so on.
Another thing they may be doing is that they may actually have a centralized "server", though it's not really a server, but simply hosts a list of IP addresses that have been found to be running the Kazaa application. That would be fairly easy to do, as they can get the IP address of your computer when you download the application, sign up for the service, or start it for the first time. It may send your IP address to a host file of some sort that all of the Kazaa applications will look in to find other Kazaa applications. That would be a more efficient way to do it in terms of bandwidth usage, though they claim that there's no centralized server, although it wouldn't really be a server per se, so who knows (besides their developers).
Again, I'm just guessing at all of this, but unless they've come out with some new top-secret invention that nobody's ever heard of, and without a centralized server that you specifically tell your client to connect to, I can't imagine it being possible any other way.
As for your other question, I'm not really following what you're asking.
Anyway, hopefully someone else will intervene here and give you their two cents, and then you can go out and buy yourself a cup of coffee! No seriously, maybe if enough people get involved, we can all come up with the next best thing for you and you can make millions. Then you can buy us all a cup of joe!
Hope that helps,
Don
|
|
|
|
|