char cmd[3]={'p','w','d'};
int n=send(m_server,cmd,3,0);
CString temp;
temp.Format("%d",n);
MessageBox(temp); int index = 0, // Integer index
iReturn; // Return value of recv function
char szClientA[200]; // ASCII string
TCHAR szClientW[200]; // Unicode string
TCHAR szError[200];
iReturn = recv (m_server, szClientA, sizeof (szClientA), 0); // Check if there is any data received. If there is, display it.
if (iReturn == SOCKET_ERROR)
{
//wsprintf (szError, TEXT("No data is received, recv failed.")
//TEXT(" Error: %d"), WSAGetLastError ());
MessageBox (TEXT("Client"));
// break;
}
else if (iReturn == 0)
{
MessageBox (TEXT("Finished receiving data"));
// break;
}
else
{
// Convert the ASCII string to a Unicode string.
for (index = 0; index <= sizeof (szClientA); index++)
szClientW[index] = szClientA[index]; // Display the string received from the server.
MessageBox (szClientW, TEXT("Received From Server"), MB_OK);
//m_status=szClientW
}请高手执教
或者给个例子吧!!!
int n=send(m_server,cmd,3,0);
CString temp;
temp.Format("%d",n);
MessageBox(temp); int index = 0, // Integer index
iReturn; // Return value of recv function
char szClientA[200]; // ASCII string
TCHAR szClientW[200]; // Unicode string
TCHAR szError[200];
iReturn = recv (m_server, szClientA, sizeof (szClientA), 0); // Check if there is any data received. If there is, display it.
if (iReturn == SOCKET_ERROR)
{
//wsprintf (szError, TEXT("No data is received, recv failed.")
//TEXT(" Error: %d"), WSAGetLastError ());
MessageBox (TEXT("Client"));
// break;
}
else if (iReturn == 0)
{
MessageBox (TEXT("Finished receiving data"));
// break;
}
else
{
// Convert the ASCII string to a Unicode string.
for (index = 0; index <= sizeof (szClientA); index++)
szClientW[index] = szClientA[index]; // Display the string received from the server.
MessageBox (szClientW, TEXT("Received From Server"), MB_OK);
//m_status=szClientW
}请高手执教
或者给个例子吧!!!
解决方案 »
- ListCtrl report风格的
- 关于VC 6.0在使用GDI+时向stdafx.h添加初始化代码的问题
- 插值法对于边缘的像素如何处理?
- 怎样进行不同类内函数之间的变量值传递?有公共的一般变量吗 怎么定义呢?
- vc出现很奇怪的事,在a工程中可以运行查找功能,在b工程中却不行
- CHM文件
- 怎么获得汉字的__笔顺__信息?我已经琢磨了近半年了,还是不得其所,有高手吗?
- 请问各位大虾:你们在类的构造函数和析构函数里都处理些什么东东?
- 数据交换?
- 什么函数能生成随机呢?
- 我现在在编写Win32程序,不想使用MFC的类库,这这样的情况下要访问数据库应该用什么方法?除了Pro*C/C++之外!
- 请教日期数值的CString类如何装换VARIANT
即:登陆,依次发送:"user username\r\n"
"pass pwd\r\n"你只要:将char cmd[3]={'p','w','d'};
改为:char cmd[]="pwd\r\n";就可以了