"dg" wrote in message news:vgfe4gpblkk5c1@corp.supernews.com...
> help me find ware my sockt went
>
> // main prog
> #include
> #include
> #include
>
> struct PACKETFRAME
>
>
> int num1;
> int num2;
> char junk[50];
> };
>
> typedef struct _PER_CLIENT_DATA
> {
> SOCKET socket;
> OVERLAPPED Overlapped;
> CHAR OutboundBuffer[1024];
> DWORD flags;
> HANDLE hEvent;
> }
> PER_CLIENT_DATA, *PPER_CLIENT_DATA;
> file://struct DATAFRAME
> file://{
> file://BYTE flag;
> file://DWORD data;
> file://}
>
> main(void)
> {
> WSADATA WsaData;
> DWORD i;
> SOCKET mylisten;
> SOCKADDR_IN addr;
> PER_CLIENT_DATA clientData[5];
> CHAR data[sizeof(PACKETFRAME)];
> DWORD err;
> PACKETFRAME thing2;
> char buffy[50];
> SOCKET sockbak;
> file://REM KEEP GAP HERE
> printf("progrm start \n");
> WSAStartup (0x0101, &WsaData);
> mylisten = socket (AF_INET, SOCK_STREAM, 0);
> ZeroMemory (&addr, sizeof (addr));
> addr.sin_port = htons(1701);
> addr.sin_family = AF_INET;
> bind (mylisten,(PSOCKADDR) & addr, sizeof (addr));
> listen (mylisten,5);
> for (i=0; i<500; i++)
> {
> clientData[i].socket= accept(mylisten,NULL,NULL);
> printf("we have connected socket %d \n",clientData[i].socket);
> err = WSAGetLastError();
> printf("socket %d \n",clientData[i].socket);
> sockbak = clientData[i].socket;
> err = recv (sockbak,(char *)data,512,0);
> printf("socket %d \n",clientData[i].socket);
> memcpy((char*)&thing2,data,sizeof(PACKETFRAME));
> printf("i receved %d %d %s \n",thing2.num1,thing2.num2,thing2.junk);
> printf("socket %d \n",clientData[i].socket);
> err = WSAGetLastError();
> printf("error # %d \n",err);
> sprintf(buffy,"you sent me %s",thing2.junk);
> strcpy(thing2.junk,buffy);
> memcpy(data,(char*)&thing2,sizeof(PACKETFRAME));
> printf("socket %d \n",clientData[i].socket);
> sockbak = clientData[i].socket;
> err = send (sockbak,(char*)data,512,0);
> printf("socket %d \n",clientData[i].socket);
> // err = send (mylisten,(char*)data,512,0);
> printf("%d err=%d",err,WSAGetLastError());
> printf("packet sent\n");
> }
> }
>
>
>
>