Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Product Lifecycle
  3. Collaboration / Beta Testing
  4. Non MFC :Client /Server

Non MFC :Client /Server

Scheduled Pinned Locked Moved Collaboration / Beta Testing
c++sysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brilliant101
    wrote on last edited by
    #1

    i have converted the program into non MFC but it complies and runs but does not send the string. 1) Client: include "stdafx.h" #include iostream.h #include conio.h #include winsock2.h #include process.h #include stdio.h UINT WINAPI SendStatus(LPVOID pParam) { cout<<"\n I am in the thread!!\n"; SOCKET client; //socket is uint WSADATA wsaData; //WSADATA structure sockaddr_in serveraddr; //sockaddr_in int wsaret=WSAStartup(0x101,&wsaData); //Initialize wsaret variable if(wsaret!=0) { cout<<"Fail to initialize:"; return 0; } struct hostent *hp; unsigned int addr; struct sockaddr_in server; char servername [30] ="localhost"; SOCKET conn; conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(conn==INVALID_SOCKET) return 0; if(inet_addr(servername)==INADDR_NONE) { hp=gethostbyname(servername); } else { addr=inet_addr(servername); hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET); } if(hp==NULL) { cout<<"Fail to get peer address:"; closesocket(conn); return 0; } server.sin_addr.s_addr=*((unsigned long*)hp->h_addr); server.sin_family=AF_INET; server.sin_port=htons(20248); if(connect(conn,(struct sockaddr*)&server,sizeof(server))) { cout<<"Fail to connect:"; closesocket(conn); return 0; } char buff[512]; sprintf(buff,"Client Process Status: \nBismillah he ar rahman ner raheem\n Allah is Great"); cout<<"\nClient Process status is being send:\n"; send(conn,buff,strlen(buff),0); closesocket(conn); cout<<"Process's Status sent:"<

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups