Ok, i'found what was wrong, the analogy with serial com cannot be used, instead i used the winsock class :
http://msdn.microsoft.com/en-us/library/windows/desktop/ms738545(v=vs.85).aspx
===================================================================================================== initialisation :
WSADATA wsaData;
int iResult;
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed: %d\n", iResult);
return 1;
}
// ======================================================================================================
// Création du Socket :
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_INET ;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
#define DEFAULT_PORT "27015"
// Resolve the server address and port
iResult = getaddrinfo("10.10.100.254","8899" , &hints, &result); //"10.10.100.254" DEFAULT_PORT "8899"
if (iResult == 0) {
printf("\n\t\tgetaddrinfo, adresse trouvee\n");
struct addrinfo *res = NULL;
int error;
for (res = result; res != NULL; res = res->ai_next)
{
char hostname[NI_MAXHOST] = "";
error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
if (error != 0)
{
fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
continue;
}
if (*hostname != '\0')
{
printf("hostname: %s\n", hostname);
ptr=res;
}
}
}else
{
printf("getaddrinfo failed: %d\n", iResult);
WSACleanup();
return 1;
}
SOCKET ConnectSocket = INVALID_SOCKET;
// Attempt to connect to the first address returned by
// the call to getaddrinfo
// Create a SOCKET for connecting to server
ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
if (ConnectSocket == INVALID_SOCKET) {
printf("Error at socket(): %ld\n", WSAGetLastError());
freeaddrinfo(result);
WSACleanup();
return 1;
}
// ======================================================================================================
// Connect to a socket :
iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
if (iResult == SOCKET_ERROR) {
wprintf(L"socket function failed with error: %ld\n", WSAGetLastError());
switch(WSAGetLastError())
{
case WSAEHOSTUNREACH:
wprintf(L"\n\t\tNo route to host. A socket operation was attempted to an unreachable host. See WSAENETUNREACH.\n");
break;
default:
break;
}
closesocket(ConnectSocket);
ConnectSocket = INVALID_SOCKET;
}
// Should really try the next address returned by getaddrinfo
// if the connect call failed
// But for this simple example we just free the resources
// returned by getaddrinfo and print an error message
freeaddrinfo(result);
if (ConnectSocket == INVALID_SOCKET) {
printf("Unable to connect to server!\n");
WSACleanup();
return 1;
}
// ======================================================================================================
// Send and recive data :
#define DEFAULT_BUFLEN 512
int recvbuflen = DEFAULT_BUFLEN;
char *sendbuf = "this is a test";
//char recvbuf[DEFAULT_BUFLEN];
// Send an initial buffer
for(int i = 0; i<100;i++)
{
if(sendCommand(ConnectSocket,i, i, 0, i)==-1) break;
Sleep(10);
}
// Disconnecting the Client : http://msdn.microsoft.com/en-us/library/windows/desktop/bb530743(v=vs.85).aspx
// shutdown the send half of the connection since no more data will be sent
iResult = shutdown(ConnectSocket, SD_SEND);
if (iResult == SOCKET_ERROR) {
printf("shutdown failed: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
return 1;
}
// cleanup
closesocket(ConnectSocket);
WSACleanup();
this worked fin for me