|
deerhunter89 wrote: char* inBuffer = (char*)malloc(2048);
int nRecv = recv(sckClient, inBuffer, 2048, 0);
if ( nRecv == sizeof(DATASTRUCT*) )
{
DATASTRUCT IncomingData;
IncomingData = (DATASTRUCT*)inBuffer;
MessageBox(hWnd, IncomingData->sParam1, "incoming data", MB_OK);
}
Unfortunately this code has some problems (and a memory leak):
a) TCP is a stream oriented protocol and you may not receive data chunks in exact the same size as they have been sent out, even if your code above works in the LAN it will fail with peers on the Internet. What you need to do in your client: collect all incoming data in a buffer, when you have enough data collected process the buffer.
b) The above code tests if you have 4 bytes of the data struct (a pointer has the size of 4 bytes on 32bit architectures). I suggest to collect incoming data until enough data was received to get a full 'DATASTRUCT' (move any possible "left overs" to the beginning of the buffer)... e.g. if(nBytesCollected >= sizeof(DATASTRUCT)) { ProcessData(m_buffer); UpdateReceiveBuffer(); }
|
|
|
|
|
// your app
#pragma pack(1)
typedef struct IpcMsg{
int iMessageServer;
int iMessageType;
int iSource;
int iRecipient;
int iMessage;
long iCircuit;
long iPartnerCircuit;
int iAutomataId;
int iCardTimeLeft;
int iAck;
char cTxt[128];
}IPCMSG;
IPCMSG Msg;
//socket part
send(m_ClientSocket, (char*)&Msg, sizeof(Msg), 0);
case FD_READ :
ZeroMemory(&Msg, sizeof(Msg));
recv(sock, (char*)&Msg, sizeof(Msg), 0);
ParcelMessage(Msg);
break;
|
|
|
|
|
my purpose is to copy selected row in a database. Error is: two few parameter.Expected1.what's wrong
void CReadDBDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString strText;
CString strSQL;
CDaoDatabase db;
db.Open("D:\\copyktt.mdb");
CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_ListControl);
ASSERT(pListCtrl != NULL);
POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = pListCtrl->GetNextSelectedItem(pos);
TRACE1("Item %d was selected!\n", nItem);
// you could do your own processing on nItem here
strText = pListCtrl->GetItemText(nItem,0);
// m_cedit.SetWindowText(strText);
strSQL.Format("INSERT INTO Table6 SELECT * FROM Table3 IN 'C:\\ktt.mdb' WHERE MyField = %s",strText);
db.Execute(strSQL);
}
}
|
|
|
|
|
I feel the problem is with Format function. Instead of embedding the datbase path directly why can't you try with replacing the text with %s and pass the value as a seperate parameter (C:\\ktt.mdb).
|
|
|
|
|
hero1995 wrote: db.Execute(strSQL);
What is the exact value of strSQL at this point?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi!
what is the equivalent of "jmp far" in Hex value? or the equivalent of other instructions
for example: the equivalent of "nop" instruction is "0x90" in Hex Value
please help me
Zo.Naderi-Iran
|
|
|
|
|
Well dear I dont think anybody remembers these values.
I can suggest you to get Intel Processors by Berry B. Brey and get complete hex codes for all.
Hang on a sec!
Try debug utility i will try too.....
Spread wat u Know!
|
|
|
|
|
jmp far EA
jmp EB
Spread wat u Know!
|
|
|
|
|
Thank you, but i don't remember these (codes), i want to use these somewhen.
is there an article or a book, that it lists this hex codes?
Zo.Naderi-Iran
|
|
|
|
|
|
Thank you!
i read these, and i ask my problems;)
Zo.Naderi-Iran
|
|
|
|
|
Hello all ,
i want to know, does worker thread and ui thread returns a value.
And if it returns a value in what form does it return a value.....
thanks in advance
|
|
|
|
|
In Win32 you exit a thread using the ExitThread function; its sole argument is the return code of the thread. The return code is accessed with the GetExitCodeThread function. If you're using a library to manage the threading then you'll have to consult its documentation or include more information in your question.
Steve
|
|
|
|
|
hi
how do i open a new property sheet on click of a page on old property sheet.
|
|
|
|
|
Just as you create the first one. Is there some problem that you are facing, can you explain something more on this scenario?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
How can I compare two strings that contain a version?
For Instance:
CString string1 = 10.2.33.4
CString string2 = 10.4.22
so in this case - string2 is higher than string1.
Is there a windows function that I can use (or something of the sort), or do I have for each string to break up the string at each '.' insert each part into an integer and compare each part of the two strings separately?
Thanks,
|
|
|
|
|
I'm not familiar with any such Window-API function ... You'll probably have to break the strings up just like you said ...
|
|
|
|
|
Hello,
if you can obtain something like 10.2.33.4 and 10.4.22.0(actually same number of characters, 00.00.00.00) then you can strip the dots out and compare the numbers directly. if the number is higher than it is more recent.
Bekir.
|
|
|
|
|
SWDevil wrote: CString string1 = 10.2.33.4
CString string2 = 10.4.22
Parse the array of characters and
Make string =10.02.33.04 & string2 = 10.04.22.00
and then compare the two.
Hope it helps
Spread wat u Know!
|
|
|
|
|
Hi all.
If you can tell me some class in C++ (NOT MFC) thet can read data file.
(Example: .xls; .dbf; . . . . . )
|
|
|
|
|
Look at ADO. Using ADO I think you will be able to read .xls , .txt , .mdb ,..... files.
|
|
|
|
|
hi
i need to write an application using VS2005 that runs both on desktop and on wince device. can anyone help me out with this? i am setting the project for two configurations but am getting a linking error when compiling for WinCE configuration.
thanks
|
|
|
|
|
WinCE has numerous limitations. With WinCe, you do not have all the APIs that you have for Windows. What is the linker error?
|
|
|
|
|
Hi All
How can i get the Address of an Member function in Regular DLL using
GetProcAddress();
I would be fine if i get an article for using an member function of an class in an dll.
And what is the purpose of .def file and how to create it.
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
See Here
The .def file is a Module-definition (.def) file that provides the linker information no exports, attributes, and other information about the program to be linked. A .def file is most useful when building a DLL.(.def) file is useful when you are not using the __declspec(dllexport) keyword to export the functions from the DLL.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|