一、DLL工程server socket代码
#include <winsock.h>
#include <stdio.h>
#pragma comment(lib,"ws2_32.lib")
#define PORT 8888
#define BUF_SIZE 1024
#define FRAME_SIZE 4096
static void DebugInitSocket(void)
{
WSADATA wsadata;
SOCKET serSocket;
SOCKET serConn;
SOCKADDR_IN clientsocket;
SOCKADDR_IN addr;
int len = sizeof(SOCKADDR);
char sendBuf[BUF_SIZE];
char receiveBuf[BUF_SIZE];
if (0 != WSAStartup(MAKEWORD(2, 2), &wsadata)) {
LOGE("socket open failed");
return;
} else {
LOGI("socket open success");
}
serSocket = socket(AF_INET, SOCK_STREAM, 0);
if (serSocket == -1){
LOGE("created socket error");
goto Exit;
}
addr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
if (-1 == bind(serSocket, (SOCKADDR*)&addr, sizeof(SOCKADDR))) {
LOGE("socket bind failed");
goto BindErr