HTML code is as follows, according to the Client connect server failed10038, always don't know what's going on, have a great god help small white me,
#include
#include
using namespace std;
# pragma comment (lib, "ws2_32. Lib")
Void main ()
{
WSADATA WSADATA;
The SOCKET SockCli;
SockCli=socket (AF_INET SOCK_STREAM, 0).
Int ret1;
Ret1=WSAStartup (MAKEWORD (2, 2), & amp; WsaData);
SOCKADDR_IN addrSer;
AddrSer. Sin_family=AF_INET;
AddrSer. Sin_port=htons (8900);
AddrSer. Sin_addr. S_un. S_addr=inet_addr (" 192.168.1.101 ");
Int ret=connect (SockCli, (SOCKADDR *) & amp; AddrSer, sizeof (SOCKADDR));
If (ret!=0)
{
Cout<" The Client connect to server failed "& lt;
The else
{
Cout<" The Client connect to server success "& lt;
Char sendbuff [1024].
Char recvbuff [1024].
While (1)
{
The recv (SockCli recvbuff, 1024, 0);
Cout<" Ser: "& lt;
Cout<" Cli: ";
Cin> Sendbuff;
If (STRCMP (sendbuff, "quit")==0)
{
break;
}
Send (SockCli sendbuff, 1024, 0);
}
Closesocket (SockCli);
WSACleanup();
}
CodePudding user response:
Ret1=WSAStartup (MAKEWORD (2, 2), & amp; WsaData);This line of code in the main function of the second line
CodePudding user response:
10038 means using invalid socket, please listen to opinions do modify upstairsCodePudding user response:
Solved thanks to the great god