|
Hi.
I am working on a network client and one of its features is download files over HTTP server, i.e. www.abc-xyz.com/files.exe. The program downloads some files successfully, but it fails to download some files. For some reason, it download the all files, but some files are unvalid in terms of CRC.
I understand that the server initially sends information about a file including its size and type (Content-Type). However, for some reason files that have bad CRC seem to miss the beginning chunk of data. In other words, the program does the file, but the first twenty bytes might contain bad CRC. Here is the algorithm of the design.
- Send request (GET)
- Call WSARecv
- On first incoming data, analyze data and determine file size.
- Analyze data and save any valid data that server might have including with file information.
- Call WSARecv
- Continue calling WSARecv and appending new data until size of data equals the size that the server sent.
I would like to know is it possible that the server sends out the data before it sends out information about the data such as size? With the algorithm above, the program can download some file, but fails other files in terms of CRC. I cannot understand how that is possible because the size of the file is correct most of the time, but even so the files have bad CRC. Another interesting fact is that the bad CRC always occurs at the beginning such as the first 20 bytes.
Thanks,
Kuphryn
|
|
|
|
|
Have you taken a look at this http://www.codeproject.com/internet/winsockintro02.asp
Seems like this is what you're doing..
|
|
|
|
|
Okay. Thanks.
Conceptually, yes, Nishant S discussed a Winsock program I am working on. However, in reality my algorithm and his algorithm are completely different.
I understand his algorithm.
Kuphryn
|
|
|
|
|
dear all,
1)i want to distribute my mfc app to a machine which does not have visual studio environment. my app is in form of an exe.
2)how do i link mfc to my app, statically or as a shared dll
can anyone shed light on it,
|
|
|
|
|
If you link statically then you do not need MFC42.dll, otherwise you do. Either way, you may need MSVCRT, it depends on if you use C runtime functions or not.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
If you link MFC staticaly, the MFC code is linked with your app, so you don't need to redistribute MFC42.dll.
Dynamic linking saves RAM on the target system, if more apps using MFC (dynamicly linked) are running simultaneously, or if your application uses DLLs created with MFC.
Pavel
Sonork 100.15206
|
|
|
|
|
dear experts,
I set up a global mouse hook for listening to mouse messages, mouseHook=SetWindowsHookEx(WH_MOUSE, MouseProc,hInstance,0);
in my MouseProc after I did my thing i called CallNextHookEx(mouseHook,nCode,wParam,lparam); however when I ran my program, if I move my mouse cursor outside of my app window, the whole desktop would disappear(possibly getting repainted) every few seconds, what's causing this weird behavior? how do I go about fixing it?
any help is appreciated
|
|
|
|
|
I am working on one application.if i want to make another application to get the focus,what api i should use to allow to get the focus.
|
|
|
|
|
I am working on one application.if i want to make another application to get the focus,what api i should use in VB to allow that application to get the focus.
|
|
|
|
|
Hmmm... This forum is generally about VC, not VB. But if you want.. it's a SetForegroundWindow. This function "puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user.". You also can try to use SetFocus function, but i do not guarantee it will work between processes
|
|
|
|
|
1. I have an application (SDI) which works with database
that is, retrieves data and the data are displayed in Edit Boxes and Statics
I want to send these data to another program, MS Word in my case
how to do this ?
2. Is it possible with ADO?
thank you.
|
|
|
|
|
try with ShellExecute function.
In ADO i'm not sure.
|
|
|
|
|
You can send data to MS Word using Automation. See this[^].
Pavel
Sonork 100.15206
|
|
|
|
|
Hi. I am using GetMenuItemInfo to retrieve information about menu items. I am using MENUITEMINFO.fMask = MIIM_DATA | MIIM_SUBMENU; and it retrieves the DATA (application-defined custom data) just fine for submenus, but not for top-level dropdown menus! But when Windows sends me WM_DRAWITEM, it fills in that DATA just fine for these top-level items! Any workaround for this?
comrade
http://comrade.ownz.com/
Souz nerushimiy respublik svobodnih
Splotila naveki velikaya Rus
Dazdrastvuet sozdanniy volei narodov
Ediniy, moguchiy Sovietskiy Souz!
|
|
|
|
|
I need help with one thing.
I don't really know how to communicate between my server and client. Am I going to use a plain string and parse it? Am I going to use a struct which is much easier because you don't need to do any painful parsing.
I want to use a struct that I send between the client and the server. But is it good or bad?
Is it something I need to think about?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
It totally depends on the problem you're trying to solve. If you're doing a web server and a web browser, then yes, a string over tcp would be ideal. Or are you copying file data? Is it really small atomic items - 4 bytes? The maybe a windows message. Or COM might be your best option.
Are these items going to be on the same system, or a true client/server?
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
T.Wilson wrote:
It totally depends on the problem you're trying to solve.
Well, I'm developing my own chatt server in order to learn socket programming "full out".
But I don't know how to create a good communication protocol and if it's going to be plain text or binary communication.
The first version of my chat will only have functionality for sending plain messages. Then when I know how to make that thing run good I will implement functionality for sending files also.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
I don't really know how to communicate between my server and client. Am I going to use a plain string and parse it?
I prefer plaintext TCP/IP communication vs binary communication, when possible.
A good example of a mixture is the Gnutella protocol: Handshake and file transfar is done in a HTTP alike plaintext protocol. while all other stuff (search requests and answers) are binary... possibly to save bandwith. Generally speaking, text protocols are flexible, easy to debug and good to understand. Binary protocols are better suited when performance matters (you know optimation is your worst enemy).
IRC is an example for a line based plaintext protocol, ICQ is an example for using binary packages. Oh, and another possibility that is available: using XML (and a library that parse data for you).
If you speak about a chat, perhaps imitate IRC protocol and use line based plaintext...
|
|
|
|
|
I've seen an IRC server that uses binary to communicate. But when you say it, I think plaintext communicating is the best.
PS. I knew you were going to answer me Moak!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi,
I'm developing server application (FTP server). It works very well and it is very stable under all platforms (win9x/2k/nt/xp). But now I have a problem. We have new LAN (100mb), very fast (file transfer from/to server about 5000 kB/s).
Here is the problem:
Under W9x, when I start uploading/downloading big file (at least 30 MB), transfer starts and everything seems to be ok. But, when I want to list directory in client (eg Total Commander), server gives no response and the machine where the server is running is totally frozen up. With one exception - file transfer that I've started before, is going on well...When I kill the connection from client, server is ok again (as well as the whole OS).
Some bug, I said. I tried to trace the error, so I put breakpoints to my socket OnReceive function. But NO DATA arrive to my socket, at least this function is never executed...I must note that this problem occurs only on this new LAN, when we had slower (10 mbps), it was ok...So where to search for the error ? I think that the bug must somewhere in CSocket/CAsyncSocket...
Thanks for anything...
Standa.
|
|
|
|
|
MFC Sockets are worthless for anything I (and lots of other people) would consder "real use". The problem is that they are still based on the Windows 3.1 sockets design, in that they need to have access to a message handler and etc.
What you're experiancing is probably message stavaration between the socket handlers and the windows handlers - you've got one socket loading down the handler, and none of the other ones can efecitivly get into it. For light use, MFC sockets can work on - for example, look at the Microsoft MSDN exampe "Chatsvr" which is a trivial messaging app using CSockets.
For more robust sockets, I would look into some of the other things here on CodeProject, in the Networking code section. You should also consider using threads to handle socket actions, so that one socket will not load down the system. This is the method I've used in a high-end 1000+ client server - one thread for each client SOCKET handle (no MFC in it).
WarFTP is open sourced I think, and is a Windows app, you might want to give that a look-see.
That's my $0.02
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
I know MFC sockets are not ideal. But they work well for me, with the exception of this one problem. Otherwise, 30-35 clients even on Win98 and server is absolutely ok...
Yes, I use separate thread for each fike transfer, that's why I can't understand this behaviour...
Is it better to use CSocket or CAsyncSocket ?
Standa.
|
|
|
|
|
s_k wrote:
Server gives no response and the machine where the server is running is totally frozen up. With one exception - file transfer that I've started before, is going on well...When I kill the connection from client, server is ok again (as well as the whole OS).
Sounds pretty odd. I think you need to give details about your socket use.
Do you use CAsnyncSocket (not CSocket)? Do you run sockets asynchronously in one thread context? Check which part is locking up your server, is it really socket core (winsock <-> application messages) or your GUI (application <-> GUI messages)?
|
|
|
|
|
I use my own class derived from CSocket, is it better to use CAsyncSocket ? I start separate working thread for each transfer, so I can't understand why one socket blocks whole OS...
|
|
|
|
|
s_k wrote:
I use my own class derived from CSocket, is it better to use CAsyncSocket ?
I would use CAsyncSocket or something else (but NOT CSocket).
s_k wrote:
I start separate working thread for each transfer, so I can't understand why one socket blocks whole OS...
There are different socket concepts, the possible alternatives are:
a) blocking servers (handling only one request at a time, then wait again blocking)
b) threaded servers (handling simultaneous requests, one thread for every new socket).
c) asynchronous server (handling simultaneous requests, one server thread will handle all sockets - CAsyncSocket will cover this)
The server model always depends on application requirements.
|
|
|
|
|