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. General Programming
  3. C / C++ / MFC
  4. Receive messages in dialog based application through socket

Receive messages in dialog based application through socket

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++wpfwcfsysadmin
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.
  • M Offline
    M Offline
    Mushtaque Nizamani
    wrote on last edited by
    #1

    I am using following code to send message to remote machine through sockets, I am calling mentioned code when a button of MFC dialog based app is clicked and it is working fine. But I don't know how to receive messages from remote machine through sockets. Can anyone please guide me how to receive messages in dialog based application through socket? WSADATA w; //Winsock startup info SOCKADDR_IN target; //Information about host int error = WSAStartup (0x0202, &w); // Fill in WSA info if (error) return 0; m_sckt = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // Create socket if (m_sckt == INVALID_SOCKET) { return 0; } target.sin_family = AF_INET; // address family Internet target.sin_port = htons (PortNo); // set server’s port number target.sin_addr.s_addr = hostname; // set server’s IP //Try connecting... if (connect(m_sckt, (SOCKADDR *)&target, sizeof(target)) == SOCKET_ERROR) //Try binding { // error return 0; } send(m_sckt, "Test", 5, 0);

    Thanks, Mushq

    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