|
« Programm3r » wrote: Thanx for the response Zac, well I would like to post the code but it is about 1200 lines (client side) & 950 lines at the (host side).
I'm not asking for the entire codebase, just for the relevant areas of code that you feel the problem may lie in.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
You're right, its hard to see exactly what you are doing from such a short code snippet. Is it safe to assume that you are using the WinSock library? If so, your server-side program is listening for incoming connections on a specific port, right? When a client requests a connection, and the server accepts it, the server should spawn a thread for that specific connection, then continue listening for another connection while the thread handles the client that just connected. The server keeps a "global" array of 'gConnectData' structures as well as an index into the array. For each client connection, the INDEX is incremented and passed to the thread that handles the client connection, therefore keeping each thread from "bumping" into any other threads as they access the array.
There is a good book entitled "Windows Sockets Network Programming", by Bob Quinn and Dave Shute, that provides good working examples of this type of application.
Not sure if I've helped you any or completely misunderstood your problem.
Scott
|
|
|
|
|
Many thanx Scott, for the reply .... Well the thing is I am using WinSock, well kinda. I'm using MarshallSoft TCP/IP DLL. But I'll have a look at the book you mentioned..
Regards
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
OK, I'll try and explain it better....
Client Side:
The client sends command to the server, these commands include the following:
CMD_QUITCMD_GET_FILECMD_GET_PCNAMECMD_STATUSFILECMD_SENDFILESCMD_SENDFILEFORFILEMD_RECEIVEFILECMD_SENDSTATUSFILESo all of these commandshave a certain purpose on the client side. Please note that there are more than one client.
The client can send files to the server and the server can send files to the client via TCP/IP. Before the file transfer begins the client(s) ask the server if the files exists? On the servers response the client(s) makes decisions. The server knows with which client(s) it's communicating, because the client(s) sends it's name (PC NAME).
Server Side:
Please note: the following happens in a loop....
The server accomidates for each of the commands that the client(s) may send. It uses a function to get the command code and returns a certain command.
after returning the command, the server sits in a loop and waits for a client(s) to connect. When the client(s) connects the server uses a function to find a free slot. After assinging the connection to a free slot, the server puts the connection into a state namely:
STATE_REQUEST In this state the commands of the client(s) get executed.
So the thing is when two clients connect at the same time (and they want to transmit & receive files) the above happens but the computer name which the server uses to know with which client it's communicating gets overwritten by the next connection. Please note that only certain file may go to certain clients.
Regards
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Out of curiousity, why not use WinInet's FTP functionality for this?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
« Programm3r » wrote: the computer name which the server uses to know with which client it's communicating gets overwritten by the next connection.
Well that would be a "bug". Something is wrong with the code, perhaps a code error or a flaw in the design. A flaw in the design would require changing the design to resolve the problem.
I assume you are using TCP (Stream) connection, yes?
Is it stateful or stateless? Depending on that answer the design is different in only one aspect otherwise it is the same:
Each connection is considered a "Session" and any "state" required is maintained with the Socket handle. Threading or Overlapped IO is used to read/write data and of course perform required logic. Your protocol indicates you could also use a finite state machine implementation.
If it is a stateless protocol then you must add session identification and maintain session in the server.
It's basically that simple. If your design does not reflect that then you are likely in for a bumpy ride.
[After further reading of your post]
« Programm3r » wrote: When the client(s) connects the server uses a function to find a free slot.
Without a requirement that enforces the need for that behavior, that is a "bad" design.
« Programm3r » wrote: When the client(s) connects the server uses a function to find a free slot.
That description makes it sound like the server is single threaded. Handling the Server socket "accept" and the client connection communications on the same thread. If that is true that is a "bad" if not "horrible" (as in dead) design. Again without being aware of any specific requirements that would force that design it is just plain wrong.
led mike
|
|
|
|
|
Does anyone know how to convert pdf to tiff via Acrobat 5 writer automation?
I need sources.
Thanks,
Dudi
|
|
|
|
|
Dudi Avramov wrote: I need sources.
And one day you will call yourself a programer? I will call you a "Copy and Paster"!
|
|
|
|
|
In my SDI CFormView based application (Visua C++, Window2000), a CFileDialog type dialog box is used to select files. The dialog box works fine if I directly click the button to bring up the dialog box. However, if i click some other buttons to run some other routines before clicking the button for bring up the dialog box, then SOMETIMES the dialog box did not come up .
The code for the button click (to bring up the dialog box) handler is shown below.
<br />
CFileDialog * Cfieldialog = new CFileDialog(true, NULL, NULL, OFN_NOCHANGEDIR|OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Text Files (*.txt)|*.txt|All Files (*.*)|*.*", NULL );<br />
<br />
Cfieldialog->DoModal();<br />
<br />
CString CStringTest = Cfieldialog->GetPathName();<br />
((CEdit*)GetDlgItem(IDC_EDIT_ExampleText))->SetWindowText((LPSTR)(LPCTSTR)Cfieldialog->GetPathName());<br />
<br />
delete Cfieldialog;<br />
<br />
<br />
This problem is biting me hard. Any help and hints would be appreciated very mcuh.
|
|
|
|
|
The filter is supposed to end with two ‘|’ characters.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I think problem is somewhere else - you said that if you click others buttons the it won't work. Try to find which exactly routine occurs unstable application proceeding.
-----------
Mila
|
|
|
|
|
Hello comunity,
how to get an pointer to an control that is on CTabCtrl placed, my problem is the grid control that is
on dialog in CTabCtrl!
Have Main Dialog with CTabCtrl, first tabitem have him own CDialog, and on that is my CGridCtrl whitch
pinter i need!
That is what i try before:
CGridCtrl* pGrid = (CGridCtrl*) ((CSecondDialog*) pMainDlg->GetTab(0))->GetDlgItem(IDC_GRID_LIST);
int iNumLines = pGrid->InsertRow(L"some text");
pGrid->SetItemText(iNumLines, 1, L"some text on column 2");
Is there any error in my cast?
regards
break;
-- modified at 9:41 Monday 20th November, 2006
|
|
|
|
|
I'm very new to C++ and haven't really touched it since 1996 in varsity. I'm now trying to build several chaotic open source projects, and I could use some help on how project structures, include directories, make files etc. all work. I'm basically looking for Teach Yourself to Structure and Build C++ Projects in One Evening, if anyone has seen it somewhere.
|
|
|
|
|
Hi
Suppose we have class that is in a dll, this class has a CString object.
I want to export this class, but I get this warning:
class 'CString' needs to have dll-interface to be used by clients of class
and then I can't access this member of class via my code.
Do you know why?
|
|
|
|
|
|
could i know how can i load active-x control in vc++ at run-time(programmatically).I will be very thankful to you , if you can throw some light on it.
Thanks & Regards,
Praveen A.
praveena@navayuga.co.in.
praveen kumar agarwal.
|
|
|
|
|
Why do you want to load it at run-time, for what reason ?
The purpose of an ActiveX control is not to be loaded at run-time.
You need to have the wrapper classes that are generated when you add the ActiveX to your project. Without these classes, how can you 'communicate' with the control ?
|
|
|
|
|
There are a couple of things worth noting here.
1) you can create a stub class based on an activeX control using VC++'s insert class wizard. This will give you an interface to its methods and properties based on the control's IDL file.
2) Call AfxEnableControlContainer(); (eg in InitInstance or somewhere early on) or nothing good will happen.
) Once you have an instance of the ActiveX stub class class you'll need to call CreateControl on it to instntiate the actual control (note: this may consist of an overridden Create function).
Then you up an running.
Tom
|
|
|
|
|
You make me doubting if I have well understood his question
For me loading the ActiveX at runtime meant that he didn't want to use class Wizard and all these things to add the control to its project but do that at runtime instead.
But we'll probably never know what he wanted to do
|
|
|
|
|
Hmmm... I suppose it depends on what he meant by "load".
I suppose he could have meant trawling through the registry or someone dragging a control onto a page etc.
I just assumed he meant using a control without having first dragged it onto the form design window.
I hope he does respond
Tom
|
|
|
|
|
i meant selecting a control from a list of control without using any wizard. After selection of control just place the same on view window at runtime. even i need to change the control property at runtime as desired by me.
It is like drag and drop control from toolbox on to view window, but instead of runtime samething i want to implement at runtime.
waiting for your reply.
Thanks in advance for the help.
Praveen A.
|
|
|
|
|
Thanks for the reply. yes, I meant adding control at runtime without using class wizard. I want to provide an option to user by which he can load active-x control at runtime and can set the property dynamically.
Thanks & Regards,
Praveen A.
praveen kumar agarwal.
|
|
|
|
|
Hi
Right then...
In order for your app to be able to behave as a container you'll have to have selected Container on the Compound Document Support form when you created your app (or you'll have to set the framework up your self). You'll also have to have a Doc/view architecture but I believe you already mentioned you were using one
One the project is created you'll find a method called OnInsertObject in your view class. If you follow the help files you'll probably be fine from here on, just remember that it's all about the IDispatch interface. If your not sure what that is you'll certainly make your life easier if you look into it.
All the best
Tom
|
|
|
|
|
Hi,
I have 2 questions?
[1] How to create a service application in vc++ ? What are the steps to install this service application and make it run??
[2] How to trap the winlogon events in this service???
A code snippet will be of great help..!!!
Sunil
|
|
|
|
|
sunilpv1982 wrote: [1] How to create a service application in vc++ ?
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|