console to dialog
-
If I test a console program (client_server) and it can work. But how to use the source code into the dialog application because when I use the console source code into the dilog that I designed, it can not send the string that I want. Can tell me how to use it in the dialog application.
-
If I test a console program (client_server) and it can work. But how to use the source code into the dialog application because when I use the console source code into the dilog that I designed, it can not send the string that I want. Can tell me how to use it in the dialog application.
This question is impossible to answer. Any code in your console app will probably translate to a dialog app, but the key thing is to put it in the right place in an event driven system so that it's called when you want it to be. Without seeing the code, it's not possible to say more. 1983ttj wrote: it can not send the string that I want What does this even mean ? Christian Graus - Microsoft MVP - C++
-
This question is impossible to answer. Any code in your console app will probably translate to a dialog app, but the key thing is to put it in the right place in an event driven system so that it's called when you want it to be. Without seeing the code, it's not possible to say more. 1983ttj wrote: it can not send the string that I want What does this even mean ? Christian Graus - Microsoft MVP - C++
Below is the code at the console application to send and receive: // Send and receive data. int bytesSent; int bytesRecv = SOCKET_ERROR; char sendbuf[300] = "Door Close"; char recvbuf[300] = ""; bytesRecv = recv( m_socket, recvbuf, 300, 0 ); prinf( "String Recv: %s\n", recvbuf ); bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 ); printf( "String Sent: %s\n", recvbuf ); It will send a "Door Close" to server. I copy this into the dialog that to send "Door Close" when I click on that button, But I dont' know how to chage it so that it can send.
-
Below is the code at the console application to send and receive: // Send and receive data. int bytesSent; int bytesRecv = SOCKET_ERROR; char sendbuf[300] = "Door Close"; char recvbuf[300] = ""; bytesRecv = recv( m_socket, recvbuf, 300, 0 ); prinf( "String Recv: %s\n", recvbuf ); bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 ); printf( "String Sent: %s\n", recvbuf ); It will send a "Door Close" to server. I copy this into the dialog that to send "Door Close" when I click on that button, But I dont' know how to chage it so that it can send.
Why would you have to change it ? The code has nothing to do with dialogs, or consoles. If it worked in the console app, and it's getting called in the dialog app, it should work there, too. Does the code compile ? Are you including the right header and lib files in your project ( if not, it won't compile ) ? Have you called WSAStartup ? Here[^] is the MSDN entry on the recv function, perhaps it can give you a clue what is in your console app, but you've failed to port to the dialog app ? I'm guessing you didn't write the console app ? Christian Graus - Microsoft MVP - C++
-
Why would you have to change it ? The code has nothing to do with dialogs, or consoles. If it worked in the console app, and it's getting called in the dialog app, it should work there, too. Does the code compile ? Are you including the right header and lib files in your project ( if not, it won't compile ) ? Have you called WSAStartup ? Here[^] is the MSDN entry on the recv function, perhaps it can give you a clue what is in your console app, but you've failed to port to the dialog app ? I'm guessing you didn't write the console app ? Christian Graus - Microsoft MVP - C++
It works in console but when I compile at dialog it hang there. It can connect between server and client but when come to send and receive, it hang there. I already add the lib
-
It works in console but when I compile at dialog it hang there. It can connect between server and client but when come to send and receive, it hang there. I already add the lib
Then there is code in the console app that's not being called in the dialog app, simple as that. I'd guess at the initialisation function I pointed out in my last post. Christian Graus - Microsoft MVP - C++
-
Then there is code in the console app that's not being called in the dialog app, simple as that. I'd guess at the initialisation function I pointed out in my last post. Christian Graus - Microsoft MVP - C++
I already do the initialisation function that you pointed in last post which is WSAStartup. For the console, it is printf but for the dialog it is not printf right?
-
I already do the initialisation function that you pointed in last post which is WSAStartup. For the console, it is printf but for the dialog it is not printf right?
Hello, May I suggest an MFC tutorial or two? Try reading here[^] for a start. If you get stuck, google, MSDN and CodeProject are your friends. From what I read in your posts, your main problem is that your code is not properly structured. My guess is that you put almost everything in your
main
. Try and put all your code in classes:CClient
andCServer
for example. Doing this, enables you to reuse your code in a dialog app for example. Behind every great black man... ... is the police. - Conspiracy brother Blog[^] -
I already do the initialisation function that you pointed in last post which is WSAStartup. For the console, it is printf but for the dialog it is not printf right?
Like the other guy said, you're obviously lost at sea. Why would printf not work in a dialog app ? What were you using instead ? Christian Graus - Microsoft MVP - C++