any lib to be added to make it work or any changes to be done?
-
hi! i compiled the following code... some error is being shown in _endthreadex and _beginthread mpr.lib and wsock32.lib is included but still not working... pls tell me if any other changes has to be made... // HEADER FILE #include #include #include #include #include #include char buffer[]="ANY DATA"; // Static Global Data /*-------------------------------------------------------------------*/ void MyFunction( void* Arg ) { SOCKET Client=(*(int *)Arg); while(1) { send(Client,buffer,100,0); } _endthreadex(0); } /*--------------------------------------------------------------------*/ void main(void) { int a,b,c,d; // For Server Address or Address of P1. int port; // For Port No of Server or Port of P1. struct sockaddr_in serv_addr,cli_addr; SOCKET Server; SOCKET Client; int clilen=sizeof(cli_addr); /***************************************************/ /* SOCKET INITIALISATION */ /***************************************************/ WSADATA WsaDat; if (WSAStartup(MAKEWORD(1,1),&WsaDat) != 0) { printf("\n\n WSA Initialization failed! STOP!!!"); exit(1); } /***************************************************/ /* SOCKET CREATION */ /***************************************************/ Server = socket(AF_INET, SOCK_STREAM, 0); if (Server == INVALID_SOCKET) { printf("\n\n Socket creation failed!STOP!!!"); exit(1); } else printf("\n\n SOCKET IS CREATED SUCCESSFULLY..."); /***************************************************/ /* SERVER ADDRESS */ /***************************************************/ serv_addr.sin_family=AF_INET; printf("\n\n ENTER THE SERVER IP "); scanf("%d%d%d%d",&a,&b,&c,&d); serv_addr.sin_addr.S_un.S_un_b.s_b1 =a ; serv_addr.sin_addr.S_un.S_un_b.s_b2 =b ; serv_addr.sin_addr.S_un.S_un_b.s_b3 =c ; serv_addr.sin_addr.S_un.S_un_b.s_b4 =d ; printf("\n\n ENTER THE PORT NO "); scanf("%d",&port); serv_addr.sin_port = htons(port); /***************************************************/ /* BIND THE SOCKET*/ /***************************************************/ if (bind(Server,(struct sockaddr *)(&serv_addr),sizeof(ser
-
hi! i compiled the following code... some error is being shown in _endthreadex and _beginthread mpr.lib and wsock32.lib is included but still not working... pls tell me if any other changes has to be made... // HEADER FILE #include #include #include #include #include #include char buffer[]="ANY DATA"; // Static Global Data /*-------------------------------------------------------------------*/ void MyFunction( void* Arg ) { SOCKET Client=(*(int *)Arg); while(1) { send(Client,buffer,100,0); } _endthreadex(0); } /*--------------------------------------------------------------------*/ void main(void) { int a,b,c,d; // For Server Address or Address of P1. int port; // For Port No of Server or Port of P1. struct sockaddr_in serv_addr,cli_addr; SOCKET Server; SOCKET Client; int clilen=sizeof(cli_addr); /***************************************************/ /* SOCKET INITIALISATION */ /***************************************************/ WSADATA WsaDat; if (WSAStartup(MAKEWORD(1,1),&WsaDat) != 0) { printf("\n\n WSA Initialization failed! STOP!!!"); exit(1); } /***************************************************/ /* SOCKET CREATION */ /***************************************************/ Server = socket(AF_INET, SOCK_STREAM, 0); if (Server == INVALID_SOCKET) { printf("\n\n Socket creation failed!STOP!!!"); exit(1); } else printf("\n\n SOCKET IS CREATED SUCCESSFULLY..."); /***************************************************/ /* SERVER ADDRESS */ /***************************************************/ serv_addr.sin_family=AF_INET; printf("\n\n ENTER THE SERVER IP "); scanf("%d%d%d%d",&a,&b,&c,&d); serv_addr.sin_addr.S_un.S_un_b.s_b1 =a ; serv_addr.sin_addr.S_un.S_un_b.s_b2 =b ; serv_addr.sin_addr.S_un.S_un_b.s_b3 =c ; serv_addr.sin_addr.S_un.S_un_b.s_b4 =d ; printf("\n\n ENTER THE PORT NO "); scanf("%d",&port); serv_addr.sin_port = htons(port); /***************************************************/ /* BIND THE SOCKET*/ /***************************************************/ if (bind(Server,(struct sockaddr *)(&serv_addr),sizeof(ser
Hi, WSAStartup Have you linked the following lib file to your project: Library Use -> Ws2_32.lib : Link WSAStartup[^] _beginthread Have you included the following header file to your project: #include <process.h> /* _beginthread, _endthread */ Link _beginthread[^] Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :)Programm3r My Blog: ^_^
-
Hi, WSAStartup Have you linked the following lib file to your project: Library Use -> Ws2_32.lib : Link WSAStartup[^] _beginthread Have you included the following header file to your project: #include <process.h> /* _beginthread, _endthread */ Link _beginthread[^] Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :)Programm3r My Blog: ^_^