|
ADTC# wrote: ClientSocket = accept(mysocket, NULL, NULL);
Upon accepting the connection, the accept() will return another socket( in ur case ClientSocket ). You should use that socket to send and receive data. But in your code you are writing like..
sendResult = send(mysocket, sendbuf, strlen(sendbuf), 0);
This need to be changed to
sendResult = send( ClientSocket, sendbuf, strlen(sendbuf), 0);
The ReceiveMsg() function also need to be chnaged..
int recvResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
|
|
|
|
|
my server side send and receive uses ClientSocket but the Client side should use mysocket that was created in the client side programming and earlier send and receive was for client and this ones for server
<code>
int SocketClass::SendMsg(char sendbuff[DEFAULT_BUFLEN])
{
int sendResult;
sendResult = send( ClientSocket, sendbuff,strlen(sendbuff),0);
if (sendResult == SOCKET_ERROR)
{
cout<<"send failed:"<<WSAGetLastError();
end();
exit(1);
}
cout<<"Message sent:"<<sendbuff;
cout<<"Bytes sent:"<< sendResult<<" bytes";
}
int SocketClass::ReceiveMsg()
{
char recvbuf[DEFAULT_BUFLEN];
int recvResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
if(recvResult>0)
cout<<"%s"<<recvbuf;
else if(recvResult == 0)
cout<<"connection closed";
else
cout<<"Receive failed";
return recvResult;
}
</code>
|
|
|
|
|
ok. So you are trying to send the data from server to client or client to server? And which function returned that error code?
|
|
|
|
|
severs sends first and client receives it and sends and acknowledgement and server should receive that and i get the same error on both server and client but this code works fine in C.
|
|
|
|
|
ADTC# wrote: i get the same error on both server and client
What I mean is it the send () function or recv () function that returns the error?
|
|
|
|
|
send() works perfectly fine its the recv() that gives me this error.
|
|
|
|
|
|
i found the error and it is error code 10055 - No Buffer Space was available. How do i allocate buffer space.
|
|
|
|
|
1. I created a project with VC6. Now I opened it with VC8, which converted the project. However, the resource tab is empty. The resource file is there, the program is running, but I don't see the resources (and can't edit them).
2. How does one start the dialog editor in VC8? The help is crap; it contains everything about the dialog editor but not how to start it.
Thanks
|
|
|
|
|
Silly question: Have you the Express Edition of VC8?
(Express Edition has NO resource editor).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Did you get any message or warning?
|
|
|
|
|
1. No, it is not the Express. It is the full professional version.
2. I do not receive any error message.
Even more strange: I started a new project in order to test this issue. It is the simple dialog with the default buttons, I have not done anything yet.
The dialog editor has been started automatically, and it works as supposed to - however, the resource tab is still empty in the new project as well.
I added a bitmap resource; I could edit it, but after having closed it, the recource tab is still empty.
Moreover, the class view tab too is empty, both in the converted and in the new project.
|
|
|
|
|
I am trying to subclass a CTEXT control in my dialog, I am using the following code.
LRESULT CALLBACK SetCommStat(HWND hItem, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT lpPaintStruct;
switch (message)
{
case WM_PAINT:
BeginPaint(hItem, &lpPaintStruct);
GetDC(hItem);
SetBkColor(hItem, crRED);
EndPaint(hItem, &lpPaintStruct);
ReleaseDC(hwndDlg, hItem);
return(0);
}
return(DefWindowProc(hItem, message, wParam, lParam));
}
I also have the following in the WM_INITDIALOG message handler.
hItemHandle = GetDlgItem(hwndDlg,IND_ONLINE);
int test = SetWindowLong(hItemHandle, GWL_WNDPROC, (LONG)SetCommStat);
1. Am I trapping the wrong message, if so what message should I trap?
2. Why has the call to SetWindowText stopped working?
Thanks for your help.
|
|
|
|
|
jonsey29847 wrote: } return(DefWindowProc(hItem, message, wParam, lParam));
Should this be CallWindowProc() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thank you for prompt reply,
I am not sure, I am taking the example from an online example example and thought that that line returns control to normal message handling.
I'll look into your suggestion.
|
|
|
|
|
Are you trying to set the background color of CStatic (CTEXT) ?
If yes, use WM_CTLCOLOR.
I hope this will serve your purpose.
Regards,
Paresh.
|
|
|
|
|
Your suggestion looks promising, Thank you very much.
|
|
|
|
|
I am trying to make an application using excel. how do i put the text data into the excel component programatically. i need to read from the file and then write it in to the excel sheet..
please give me some ideas.
thanks
|
|
|
|
|
have you noticed you were on a C/C++ forum ?
if you want to code with VBA, then you're not on the right board (nor even on the right site...)
|
|
|
|
|
i guess i am on the right board... i am working on mfc..
|
|
|
|
|
See here.
For past discussions, see here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi david,
this is not what i wanted to do. i want to embed the control into the dialog box. and run the application.
i wan to import the activex component "Microsoft Office SpreadSheet"
that is available on insert activex component.
where can i get some examples for that?
well the link that u send me was quite useful.
thanks in advance
|
|
|
|
|
Chandrasekharanp wrote: i wan to import the activex component "Microsoft Office SpreadSheet"
that is available on insert activex component.
Ok, so what exactly are you having trouble with?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I had wirtten a query sometime back. now there is another problem. when i embed this control into the dialog box and compile the application i am getting some 35 errors.
the error is something lime this
error C2440: 'type cast' : cannot convert from 'struct IDispatch *' to 'class CSpreadsheet'
No constructor could take the source type, or constructor overload resolution was ambiguous.
what is the meaning of this??
is it because the control is not reqistered properly?
Awaiting a favourable reply.
Thanks
|
|
|
|
|
Chandrasekharanp wrote: is it because the control is not reqistered properly?
I hardly believe is it.
Try to post some code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|